]> git.parisson.com Git - pdf.js.git/commitdiff
fixed case when font cannot be found
authorsbarman <sbarman@L3CWZ5T.(none)>
Fri, 8 Jul 2011 17:04:52 +0000 (10:04 -0700)
committersbarman <sbarman@L3CWZ5T.(none)>
Fri, 8 Jul 2011 17:04:52 +0000 (10:04 -0700)
fonts.js
pdf.js

index c275227a9ec0247ad81923481b7d071cec6f8267..093b9ec313b18e33195c1e8ceb7198555021c486 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -69,7 +69,11 @@ var Fonts = (function Fonts() {
         var sizes = current.sizes;
         if (!(measureCache = sizes[size]))
           measureCache = sizes[size] = Object.create(null);
+      } else {
+        charsCache = null;
+        measureCache = null
       }
+
       ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"';
     },
     charsToUnicode: function fonts_chars2Unicode(chars) {
diff --git a/pdf.js b/pdf.js
index c30c896142211a974ac2fad27ed19973c2af563f..85490baee70e41bce3cacd0d3cf488c7e75dbd5e 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3930,10 +3930,12 @@ var CanvasGraphics = (function() {
         text = Fonts.charsToUnicode(text);
         this.ctx.translate(this.current.x, -1 * this.current.y);
 
-        var font = Fonts.lookupById(this.current.font.id);
-        if (font && font.properties.textMatrix)
-          this.ctx.transform.apply(this.ctx, font.properties.textMatrix);
-
+        var font = this.current.font;
+        if (font) {
+          var fontInfo = Fonts.lookupById(font.id);
+          if (fontInfo && fontInfo.properties.textMatrix)
+            this.ctx.transform.apply(this.ctx, fontInfo.properties.textMatrix);
+        }
         this.ctx.fillText(text, 0, 0);
         this.current.x += Fonts.measureText(text);
       }