]> git.parisson.com Git - pdf.js.git/commitdiff
Moving defaultWidth into the charsToGlyphs function
authornotmasteryet <async.processingjs@yahoo.com>
Sun, 18 Sep 2011 14:11:31 +0000 (09:11 -0500)
committernotmasteryet <async.processingjs@yahoo.com>
Sun, 18 Sep 2011 14:11:31 +0000 (09:11 -0500)
fonts.js
pdf.js

index 3beac011afd122a98cc360dad58672dec81b9b4c..ce4215663d19c2b145f0ca4f334f69963d151bd0 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -1373,7 +1373,10 @@ var Font = (function Font() {
           var glyph = encoding[charcode];
           if ('undefined' == typeof(glyph)) {
             warn('Unencoded charcode ' + charcode);
-            glyph = { unicode: charcode };
+            glyph = {
+              unicode: charcode,
+              width: this.defaultWidth
+            };
           }
           glyphs.push(glyph);
           // placing null after each word break charcode (ASCII SPACE)
@@ -1387,7 +1390,10 @@ var Font = (function Font() {
           var glyph = encoding[charcode];
           if ('undefined' == typeof(glyph)) {
             warn('Unencoded charcode ' + charcode);
-            glyph = { unicode: charcode };
+            glyph = {
+              unicode: charcode,
+              width: this.defaultWidth
+            };
           }
           glyphs.push(glyph);
           if (charcode == 0x20)
diff --git a/pdf.js b/pdf.js
index 9757921418bce53b012e1276b625f73ec72313eb..5c3102b850ddaccc39ea374237ba4e72a26de5d2 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -4989,7 +4989,6 @@ var CanvasGraphics = (function() {
       ctx.transform.apply(ctx, font.textMatrix || IDENTITY_MATRIX);
 
       var glyphs = font.charsToGlyphs(text);
-      var defaultCharWidth = font.defaultWidth;
       var fontSize = current.fontSize;
       var charSpacing = current.charSpacing;
       var wordSpacing = current.wordSpacing;
@@ -5010,7 +5009,7 @@ var CanvasGraphics = (function() {
           String.fromCharCode(0xD800 | ((unicode - 0x10000) >> 10),
           0xDC00 | (unicode & 0x3FF)) : String.fromCharCode(unicode);
 
-        var charWidth = (glyph.width || defaultCharWidth) * fontSize * 0.001;
+        var charWidth = glyph.width * fontSize * 0.001;
         charWidth += charSpacing;
 
         ctx.fillText(char, width, 0);