]> git.parisson.com Git - pdf.js.git/commitdiff
eagerly translate all fonts (a no-op currently)
authorAndreas Gal <andreas.gal@gmail.com>
Wed, 15 Jun 2011 06:34:11 +0000 (23:34 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Wed, 15 Jun 2011 06:34:11 +0000 (23:34 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 23f2497812fc204833f85363db3f4444b6a038bb..5aec4e76abb27d03875a64e49e42361c0981be3e 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1677,6 +1677,10 @@ var CanvasGraphics = (function() {
     const EO_CLIP = {};
 
     constructor.prototype = {
+        translateFont: function(fontDict) {
+            return fontDict;
+        },
+
         beginDrawing: function(mediaBox) {
             var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
             this.ctx.save();
@@ -1698,7 +1702,6 @@ var CanvasGraphics = (function() {
         },
 
         compile: function(stream, xref, resources) {
-            console.log("compiling");
             var xobjs = xref.fetchIfRef(resources.get("XObject")) || new Dict();
 
             var parser = new Parser(new Lexer(stream), false);
@@ -1739,6 +1742,15 @@ var CanvasGraphics = (function() {
                                 args[0].code = this.compile(xobj, xref, xobj.dict.get("Resources"));
                             }
                         }
+                    } else if (cmd == "Tf") { // eagerly collect all fonts
+                        var fontRes = resources.get("Font");
+                        if (fontRes) {
+                            fontRes = xref.fetchIfRef(fontRes);
+                            var font = xref.fetchIfRef(fontRes.get(args[0].name));
+                            assertWellFormed(IsDict(font));
+                            if (!font.translated)
+                                font.translated = this.translateFont(font);
+                        }
                     }
 
                     src += "this.";