]> git.parisson.com Git - pdf.js.git/commitdiff
Basic support for the embedded font file of CIDFontType0
authorVivien Nicolas <21@vingtetun.org>
Mon, 12 Sep 2011 16:32:46 +0000 (18:32 +0200)
committerVivien Nicolas <21@vingtetun.org>
Mon, 12 Sep 2011 16:32:46 +0000 (18:32 +0200)
fonts.js

index 6a361e60e1826694f5c5160b220792d76969e96f..beecf045981912583d5aac2d1a573d08aa1bc1a7 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -448,7 +448,7 @@ var Font = (function Font() {
         this.mimetype = 'font/opentype';
 
         var subtype = properties.subtype;
-        var cff = (subtype === 'Type1C') ?
+        var cff = (subtype == 'Type1C' || properties.type == 'CIDFontType0') ?
           new Type2CFF(file, properties) : new CFF(name, file, properties);
 
         // Wrap the CFF data inside an OTF font file
@@ -2256,11 +2256,16 @@ var Type2CFF = (function() {
 
       var bytes = this.bytes;
 
+      var privateDict = {};
       var privateInfo = topDict.Private;
-      var privOffset = privateInfo[1], privLength = privateInfo[0];
-      var privBytes = bytes.subarray(privOffset, privOffset + privLength);
-      baseDict = this.parseDict(privBytes);
-      var privDict = this.getPrivDict(baseDict, strings);
+      if (privateInfo) {
+        var privOffset = privateInfo[1], privLength = privateInfo[0];
+        var privBytes = bytes.subarray(privOffset, privOffset + privLength);
+        baseDict = this.parseDict(privBytes);
+        privateDict = this.getPrivDict(baseDict, strings);
+      } else {
+        privateDict.defaultWidthX = properties.defaultWidth;
+      }
 
       var charStrings = this.parseIndex(topDict.CharStrings);
       var charset = this.parseCharsets(topDict.charset,
@@ -2306,7 +2311,7 @@ var Type2CFF = (function() {
       // charstrings contains info about glyphs (one element per glyph
       // containing mappings for {unicode, width})
       var charstrings = this.getCharStrings(charset, charStrings,
-                                            privDict, this.properties);
+                                            privateDict, this.properties);
 
       // create the mapping between charstring and glyph id
       var glyphIds = [];
@@ -2323,10 +2328,8 @@ var Type2CFF = (function() {
     },
 
     getCharStrings: function cff_charstrings(charsets, charStrings,
-                                             privDict, properties) {
-      var defaultWidth = privDict['defaultWidthX'];
-      var nominalWidth = privDict['nominalWidthX'];
-
+                                             privateDict, properties) {
+      var defaultWidth = privateDict['defaultWidthX'];
       var charstrings = [];
       var differences = properties.differences;
       var index = 0;