Fixes lineWidth/scale calculation for the fonts

This commit is contained in:
Yury Delendik 2012-11-02 08:10:22 -05:00
parent 9d3afdd2e0
commit 37fb625e87

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])));
}
};