From 9307c35c176f9ca2b9c52f09215571e44ec02b65 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 29 Nov 2017 16:00:59 +0100 Subject: [PATCH] Improve vertical font placement in Firefox --- src/ol/render/canvas/textreplay.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/render/canvas/textreplay.js b/src/ol/render/canvas/textreplay.js index d19beae119..4b5b795d41 100644 --- a/src/ol/render/canvas/textreplay.js +++ b/src/ol/render/canvas/textreplay.js @@ -323,19 +323,19 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey if (fillKey) { context.fillStyle = fillState.fillStyle; } - context.textBaseline = 'top'; + context.textBaseline = 'middle'; context.textAlign = 'center'; var leftRight = (0.5 - align); var x = align * label.width / scale + leftRight * strokeWidth; var i; if (strokeKey) { for (i = 0; i < numLines; ++i) { - context.strokeText(lines[i], x + leftRight * widths[i], 0.5 * strokeWidth + i * lineHeight); + context.strokeText(lines[i], x + leftRight * widths[i], 0.5 * (strokeWidth + lineHeight) + i * lineHeight); } } if (fillKey) { for (i = 0; i < numLines; ++i) { - context.fillText(lines[i], x + leftRight * widths[i], 0.5 * strokeWidth + i * lineHeight); + context.fillText(lines[i], x + leftRight * widths[i], 0.5 * (strokeWidth + lineHeight) + i * lineHeight); } } }