]> git.parisson.com Git - pdf.js.git/commitdiff
Ensure things work for default fonts like Arial
authorJulian Viereck <julian.viereck@gmail.com>
Fri, 9 Sep 2011 01:34:54 +0000 (18:34 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 16:05:04 +0000 (09:05 -0700)
fonts.js
pdf.js
worker.js

index 69bb50590ca91f3e296b7ae3dd2edbb8d54b846b..0ca75e88a6510c1a45a21464675022dab50e1697 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -173,7 +173,7 @@ var FontLoader = {
       document.documentElement.removeEventListener(
         'pdfjsFontLoad', checkFontsLoaded, false);
 
-      callback();
+      callback(objs);
       return true;
     }
 
@@ -450,6 +450,8 @@ var Font = (function Font() {
   var constructor = function font_constructor(name, file, properties) {
     this.name = name;
     this.encoding = properties.encoding;
+    this.glyphs = properties.glyphs;
+    this.loadedName = properties.loadedName;
     this.sizes = [];
 
     var names = name.split('+');
@@ -477,7 +479,6 @@ var Font = (function Font() {
       // name ArialBlack for example will be replaced by Helvetica.
       this.black = (name.search(/Black/g) != -1);
 
-      this.loadedName = fontName.split('-')[0];
       this.loading = false;
       return;
     }
@@ -514,14 +515,13 @@ var Font = (function Font() {
     this.type = properties.type;
     this.textMatrix = properties.textMatrix;
     this.composite = properties.composite;
-    this.loadedName = properties.loadedName;
     
     // TODO: Remove this once we can be sure nothing got broken to du changes
     // in this commit.
     if (!this.loadedName) {
       throw "There has to be a `loadedName`";
     }
-    
+
     this.loading = true;
   };
 
diff --git a/pdf.js b/pdf.js
index 941c3c38e068cceed6cd23ca3b4cefb4a44bdfd2..3a2aff3e0c5a3e1beda1d0433e3dceb60c353cc1 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3427,9 +3427,9 @@ var Page = (function() {
     },
     
     ensureFonts: function(fonts, callback) {
-      var fontObjs = FontLoader.bind(
+      FontLoader.bind(
         fonts,
-        function() {
+        function(fontObjs) {
           // Rebuild the FontsMap. This is emulating the behavior of the main
           // thread.
           if (fontObjs) {
index c0cf7c29d155cd0c60e8893e8e0174c164e01940..23cc9ae14d410245d92201581da5091fa4edaabf 100644 (file)
--- a/worker.js
+++ b/worker.js
@@ -134,19 +134,22 @@ var WorkerPDFDoc = (function() {
       for (var i = 0; i < fonts.length; i++) {
         var font = fonts[i];
         
-        var fontFileDict = new Dict();
-        fontFileDict.map = font.file.dict.map;
+        // Some fonts don't have a file, e.g. the build in ones like Arial.
+        if (font.file) {
+          var fontFileDict = new Dict();
+          fontFileDict.map = font.file.dict.map;
 
-        var fontFile = new Stream(font.file.bytes, font.file.start,
-                                  font.file.end - font.file.start, fontFileDict);
+          var fontFile = new Stream(font.file.bytes, font.file.start,
+                                    font.file.end - font.file.start, fontFileDict);
                                
-        // Check if this is a FlateStream. Otherwise just use the created 
-        // Stream one. This makes complex_ttf_font.pdf work.
-        var cmf = font.file.bytes[0];
-        if ((cmf & 0x0f) == 0x08) {
-          font.file = new FlateStream(fontFile);
-        } else {
-          font.file = fontFile;
+          // Check if this is a FlateStream. Otherwise just use the created 
+          // Stream one. This makes complex_ttf_font.pdf work.
+          var cmf = font.file.bytes[0];
+          if ((cmf & 0x0f) == 0x08) {
+            font.file = new FlateStream(fontFile);
+          } else {
+            font.file = fontFile;
+          }          
         }
       }