Merge pull request #2340 from yurydelendik/issue-2334

Fixes lineWidth/scale calculation for the fonts
This commit is contained in:
Brendan Dahl 2012-11-02 09:24:13 -07:00
commit e91e6a7f65

View File

@ -799,7 +799,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.applyTextTransforms();
var lineWidth = current.lineWidth;
var scale = Math.abs(current.textMatrix[0] * fontMatrix[0]);
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
var a2 = fontMatrix[0], b2 = fontMatrix[1];
var scale = Math.sqrt((a1 * a1 + b1 * b1) * (a2 * a2 + b2 * b2));
if (scale == 0 || lineWidth == 0)
lineWidth = this.getSinglePixelWidth();
else
@ -1340,7 +1342,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
var inverse = this.ctx.mozCurrentTransformInverse;
return Math.abs(inverse[0] + inverse[2]);
// max of the current horizontal and vertical scale
return Math.sqrt(Math.max(
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
}
};