From 0ef077c44c7ed1fc447acf1aff96ba2c18ee1412 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Tue, 14 Jun 2011 23:34:11 -0700 Subject: [PATCH] eagerly translate all fonts (a no-op currently) --- pdf.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index 23f249781..5aec4e76a 100644 --- 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.";