diff --git a/src/ol/render/canvas/textreplay.js b/src/ol/render/canvas/textreplay.js index d39abc05bf..2ff5fd3792 100644 --- a/src/ol/render/canvas/textreplay.js +++ b/src/ol/render/canvas/textreplay.js @@ -326,7 +326,7 @@ ol.render.canvas.TextReplay.prototype.getImage_ = function(text, fill, stroke) { context.font = textState.font; if (stroke) { context.strokeStyle = strokeState.strokeStyle; - context.lineWidth = strokeState.lineWidth; + context.lineWidth = strokeWidth * pixelRatio; context.lineCap = strokeState.lineCap; context.lineJoin = strokeState.lineJoin; context.miterLimit = strokeState.miterLimit; diff --git a/test/rendering/ol/style/expected/text-canvas-hidpi.png b/test/rendering/ol/style/expected/text-canvas-hidpi.png new file mode 100644 index 0000000000..4c8a444edb Binary files /dev/null and b/test/rendering/ol/style/expected/text-canvas-hidpi.png differ diff --git a/test/rendering/ol/style/text.test.js b/test/rendering/ol/style/text.test.js index cc5e3fba4f..0329a58c5d 100644 --- a/test/rendering/ol/style/text.test.js +++ b/test/rendering/ol/style/text.test.js @@ -17,14 +17,14 @@ describe('ol.rendering.style.Text', function() { var map, vectorSource; - function createMap(renderer) { + function createMap(renderer, opt_pixelRatio) { vectorSource = new ol.source.Vector(); var vectorLayer = new ol.layer.Vector({ source: vectorSource }); map = new ol.Map({ - pixelRatio: 1, + pixelRatio: opt_pixelRatio || 1, target: createMapDiv(200, 200), renderer: renderer, layers: [vectorLayer], @@ -154,6 +154,12 @@ describe('ol.rendering.style.Text', function() { expectResemble(map, 'rendering/ol/style/expected/text-rotated-canvas.png', IMAGE_TOLERANCE, done); }); + it('renders correct stroke with pixelRatio != 1', function(done) { + createMap('canvas', 2); + createFeatures(); + expectResemble(map, 'rendering/ol/style/expected/text-canvas-hidpi.png', IMAGE_TOLERANCE, done); + }); + it('renders multiline text with alignment options', function(done) { createMap('canvas'); var feature;