]> git.parisson.com Git - pdf.js.git/commitdiff
used width info in fontDict
authorsbarman <sbarman@L3CWZ5T.(none)>
Wed, 20 Jul 2011 19:57:47 +0000 (12:57 -0700)
committersbarman <sbarman@L3CWZ5T.(none)>
Wed, 20 Jul 2011 19:57:47 +0000 (12:57 -0700)
fonts.js
pdf.js

index e241bb2f99cd52a26a40cfc328e7a0e14525ff09..7ca0daa3007b88b6b0fccc19a528d3fa52334499 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -399,6 +399,18 @@ var Font = (function() {
           var cff = new CFF(name, file, properties);
         }
 
+        var widths = properties.glyphWidths;
+        if (widths) {
+          var charstrings = cff.charstrings;
+          for (var i = 0, ii = charstrings.length; i < ii; ++i) {
+            var charstring  = charstrings[i];
+            var unicode = charstring.unicode;
+            var width = widths[unicode];
+            if (width)
+              charstring.width = width;
+          }
+        }
+
         // Wrap the CFF data inside an OTF font file
         data = this.convert(name, cff, properties);
         break;
diff --git a/pdf.js b/pdf.js
index 5ce22955c2ff410554ea1190ed339210fa1a9b98..8e30858bfc8a59a897efae73bca97fe7aea48dd2 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3820,9 +3820,22 @@ var PartialEvaluator = (function() {
           fileType = fileType.name;
       }
 
+      var widths = fontDict.get('Widths');
+      var firstChar = fontDict.get('FirstChar');
+      var lastChar = fontDict.get('LastChar');
+      if (widths) {
+        var glyphWidths = [];
+        for (var i = 0; i < firstChar; ++i)
+          glyphWidths.push(0);
+        
+        for (var i = 0, ii = widths.length; i < ii; ++i)
+          glyphWidths.push(widths[i]);
+      }
+
       var properties = {
         type: subType.name,
         subtype: fileType,
+        glyphWidths: glyphWidths,
         encoding: encodingMap,
         charset: charset,
         firstChar: fontDict.get('FirstChar'),