From 5379749d4be771f0dd22b21c698fe07db56ef036 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 16 May 2016 12:15:00 +0200 Subject: [PATCH] Try to prevent `CanvasGraphics_getSinglePixelWidth` from intermittently returning incorrect values in Firefox (issue 7188) Fixes 7188. --- src/display/canvas.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/display/canvas.js b/src/display/canvas.js index 732d2ee9a..9ab09d06d 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2298,7 +2298,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { }, getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { if (this.cachedGetSinglePixelWidth === null) { + // NOTE: The `save` and `restore` commands used below is a workaround + // that is necessary in order to prevent `mozCurrentTransformInverse` + // from intermittently returning incorrect values in Firefox, see: + // https://github.com/mozilla/pdf.js/issues/7188. + this.ctx.save(); var inverse = this.ctx.mozCurrentTransformInverse; + this.ctx.restore(); // max of the current horizontal and vertical scale this.cachedGetSinglePixelWidth = Math.sqrt(Math.max( (inverse[0] * inverse[0] + inverse[1] * inverse[1]),