]> git.parisson.com Git - pdf.js.git/commitdiff
Make worker code work with latest font code changes
authorJulian Viereck <julian.viereck@gmail.com>
Wed, 29 Jun 2011 12:26:38 +0000 (14:26 +0200)
committerJulian Viereck <julian.viereck@gmail.com>
Wed, 29 Jun 2011 12:26:38 +0000 (14:26 +0200)
pdf.js
worker/client.js

diff --git a/pdf.js b/pdf.js
index 33a21e38cfcf7a52969f2130703beb12776f4804..349589016e1a251074d43b4d1898aa3ffbdf8c2c 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3807,23 +3807,21 @@ var CanvasGraphics = (function() {
             if (fontDescriptor && fontDescriptor.num) {
                 var fontDescriptor = this.xref.fetchIfRef(fontDescriptor);
                 fontName = fontDescriptor.get("FontName").name.replace("+", "_");
-                Fonts.setActive(fontName, size);
             }
 
             if (!fontName) {
                 // TODO: fontDescriptor is not available, fallback to default font
-                this.current.fontSize = size;
-                this.ctx.font = this.current.fontSize + 'px sans-serif';
-                Fonts.setActive("sans-serif", this.current.fontSize);
-                return;
+                fontName = "sans-serif";
             }
 
             this.current.fontName = fontName;
             this.current.fontSize = size;
 
-            this.ctx.font = this.current.fontSize + 'px "' + fontName + '"';
             if (this.ctx.$setFont) {
-              this.ctx.$setFont(fontName);
+              this.ctx.$setFont(fontName, size);
+            } else {
+              this.ctx.font = size + 'px "' + fontName + '"';
+              Fonts.setActive(fontName, size);
             }
         },
         setTextRenderingMode: function(mode) {
index 84e44b94cc5da10d0416c8d42303fcd08ed116de..960e974967b42b3d6c225fa4f34fec1086e1110c 100644 (file)
@@ -250,9 +250,10 @@ function WorkerPDFDoc(canvas) {
       }
       this.strokeStyle = pattern;
     },
-    
-    "$setFont": function(name) {
-      Fonts.active = name;
+
+    "$setFont": function(name, size) {
+      this.font = size + 'px "' + name + '"';
+      Fonts.setActive(name, size);
     }
   }