]> git.parisson.com Git - pdf.js.git/commitdiff
Refactor translateFont() to be more readable - part2
authorVivien Nicolas <21@vingtetun.org>
Wed, 7 Sep 2011 17:34:53 +0000 (19:34 +0200)
committerVivien Nicolas <21@vingtetun.org>
Wed, 7 Sep 2011 17:34:53 +0000 (19:34 +0200)
fonts.js
pdf.js

index bd569308e3db84f98191782e541d3b117dfb4f70..659c5157efa242ed31014c1ca26bd942aec77000 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -1131,8 +1131,8 @@ var Font = (function Font() {
           for (i = 0; i < numGlyphs; i++)
             encoding[i] = i + kCmapGlyphOffset;
         } else {
-          for (var i in encoding)
-            encoding[i] = encoding[i] + kCmapGlyphOffset;
+          for (var code in encoding)
+            encoding[code] += kCmapGlyphOffset;
         }
 
         if (!cmap) {
diff --git a/pdf.js b/pdf.js
index cdbdd4180ac59de7b3f1d5da7b2feed2b050b29f..f9f3654f9552044d06c1e049c7e067b6c20dcc1d 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -4367,16 +4367,16 @@ var PartialEvaluator = (function() {
           }
         }
       }
-
       return glyphs;
     },
 
     translateFont: function(dict, xref, resources) {
-      var subType = dict.get('Subtype');
-      assertWellFormed(IsName(subType), 'invalid font Subtype');
+      var baseDict = dict;
+      var type = dict.get('Subtype');
+      assertWellFormed(IsName(type), 'invalid font Subtype');
 
       var composite = false
-      if (subType.name == 'Type0') {
+      if (type.name == 'Type0') {
         // If font is a composite
         //  - get the descendant font
         //  - set the type according to the descendant font
@@ -4390,8 +4390,8 @@ var PartialEvaluator = (function() {
 
         dict = xref.fetch(IsRef(df) ? df : df[0]);
 
-        subType = dict.get('Subtype');
-        assertWellFormed(IsName(subType), 'invalid font Subtype');
+        type = dict.get('Subtype');
+        assertWellFormed(IsName(type), 'invalid font Subtype');
         composite = true;
       }
 
@@ -4417,7 +4417,7 @@ var PartialEvaluator = (function() {
         }
         return {
           name: baseFontName,
-          dict: dict,
+          dict: baseDict,
           properties: {
             encoding: map
           }
@@ -4440,9 +4440,9 @@ var PartialEvaluator = (function() {
       if (fontFile) {
         fontFile = xref.fetchIfRef(fontFile);
         if (fontFile.dict) {
-          var fileType = fontFile.dict.get('Subtype');
-          if (fileType)
-            fileType = fileType.name;
+          var subtype = fontFile.dict.get('Subtype');
+          if (subtype)
+            subtype = subtype.name;
 
           var length1 = fontFile.dict.get('Length1');
           if (!IsInt(length1))
@@ -4455,8 +4455,8 @@ var PartialEvaluator = (function() {
       }
 
       var properties = {
-        type: subType.name,
-        subtype: fileType,
+        type: type.name,
+        subtype: subtype,
         file: fontFile,
         length1: length1,
         length2: length2,
@@ -4484,11 +4484,10 @@ var PartialEvaluator = (function() {
         properties.widths[firstChar++] = widths[i];
 
       properties.glyphs = this.extractEncoding(dict, xref, properties);
-      log(properties.encoding);
 
       return {
         name: fontName.name,
-        dict: dict,
+        dict: baseDict,
         file: fontFile,
         properties: properties
       };