Take pixel ratio into account for text stroke
This commit is contained in:
committed by
Tim Schaub
parent
90b08cdc1c
commit
84f083af86
@@ -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;
|
||||
|
||||
BIN
test/rendering/ol/style/expected/text-canvas-hidpi.png
Normal file
BIN
test/rendering/ol/style/expected/text-canvas-hidpi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user