Merge pull request #1921 from fredj/text-offset

Scale the text offset by the device's pixel ratio
This commit is contained in:
Frédéric Junod
2014-03-28 15:37:12 +01:00
2 changed files with 6 additions and 4 deletions

View File

@@ -960,8 +960,10 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
textTextBaseline : ol.render.canvas.defaultTextBaseline
};
this.text_ = goog.isDef(textText) ? textText : '';
this.textOffsetX_ = goog.isDef(textOffsetX) ? textOffsetX : 0;
this.textOffsetY_ = goog.isDef(textOffsetY) ? textOffsetY : 0;
this.textOffsetX_ =
goog.isDef(textOffsetX) ? (this.pixelRatio_ * textOffsetX) : 0;
this.textOffsetY_ =
goog.isDef(textOffsetY) ? (this.pixelRatio_ * textOffsetY) : 0;
this.textRotation_ = goog.isDef(textRotation) ? textRotation : 0;
this.textScale_ = this.pixelRatio_ * (goog.isDef(textScale) ?
textScale : 1);

View File

@@ -346,9 +346,9 @@ ol.render.canvas.Replay.prototype.replay_ = function(
goog.asserts.assert(goog.isString(instruction[3]));
text = /** @type {string} */ (instruction[3]);
goog.asserts.assert(goog.isNumber(instruction[4]));
var offsetX = /** @type {number} */ (instruction[4]);
var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio;
goog.asserts.assert(goog.isNumber(instruction[5]));
var offsetY = /** @type {number} */ (instruction[5]);
var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio;
goog.asserts.assert(goog.isNumber(instruction[6]));
rotation = /** @type {number} */ (instruction[6]);
goog.asserts.assert(goog.isNumber(instruction[7]));