From: Artur Adib Date: Tue, 31 Jan 2012 18:20:05 +0000 (-0500) Subject: Merge branch 'refs/heads/master' into issue-1049 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=7873ec966bb6ef717efd4e7a71abbdfc9aa998c7;p=pdf.js.git Merge branch 'refs/heads/master' into issue-1049 Conflicts: src/canvas.js --- 7873ec966bb6ef717efd4e7a71abbdfc9aa998c7 diff --cc src/canvas.js index 0a73e03,d0b0064..f4815a6 --- a/src/canvas.js +++ b/src/canvas.js @@@ -547,32 -546,12 +547,32 @@@ var CanvasGraphics = (function CanvasGr }, setFont: function canvasGraphicsSetFont(fontRefName, size) { var fontObj = this.objs.get(fontRefName).fontObj; + var current = this.current; - if (!fontObj) { + if (!fontObj) - throw 'Can\'t find font for ' + fontRefName; + error('Can\'t find font for ' + fontRefName); + + // Slice-clone matrix so we can manipulate it without affecting original + if (fontObj.fontMatrix) + current.fontMatrix = fontObj.fontMatrix.slice(0); + else + current.fontMatrix = IDENTITY_MATRIX.slice(0); + + // A valid matrix needs all main diagonal elements to be non-zero + // This also ensures we bypass FF bugzilla bug #719844. + if (current.fontMatrix[0] === 0 || + current.fontMatrix[3] === 0) { + warn('Invalid font matrix for font ' + fontRefName); } - var name = fontObj.loadedName || 'sans-serif'; + // The spec for Tf (setFont) says that 'size' specifies the font 'scale', + // and in some docs this can be negative (inverted x-y axes). + // We implement this condition with fontMatrix. + if (size < 0) { + size = -size; + current.fontMatrix[0] *= -1; + current.fontMatrix[3] *= -1; + } this.current.font = fontObj; this.current.fontSize = size;