From 37fb625e87546dda8b239e437eececfa1a02447b Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Fri, 2 Nov 2012 08:10:22 -0500 Subject: [PATCH] Fixes lineWidth/scale calculation for the fonts --- src/canvas.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index a32ba44a0..fdda9f88f 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -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]))); } };