]> git.parisson.com Git - pdf.js.git/commitdiff
Move ensureFont code part of Page into its own function
authorJulian Viereck <julian.viereck@gmail.com>
Mon, 5 Sep 2011 23:40:15 +0000 (16:40 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 15:16:49 +0000 (08:16 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 7122c0eb4c4ade96f1e251cb9df76c1ddc1f4773..475137475ad5deec45339318cd62f37c0d062811 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3356,6 +3356,7 @@ var Page = (function() {
       }
       return shadow(this, 'rotate', rotate);
     },
+
     startRendering: function(canvasCtx, continuation) {
       var self = this;
       var stats = self.stats;
@@ -3399,28 +3400,14 @@ var Page = (function() {
         fonts.push(font);
       }
 
-      var fontObjs = FontLoader.bind(
-        fonts,
-        function() {
-          // Rebuild the FontsMap. This is emulating the behavior of the main
-          // thread.
-          if (fontObjs) {
-            // Replace the FontsMap hash with the fontObjs.
-            for (var i = 0; i < fontObjs.length; i++) {
-              FontsMap[fontObjs[i].loadedName] = {fontObj: fontObjs[i]};
-            }
-          }
-
-          stats.fonts = Date.now();
-          images.notifyOnLoad(function() {
-            stats.images = Date.now();
-            displayContinuation();
-          });
-        }
-      );
+      this.ensureFonts(fonts, function() {
+        images.notifyOnLoad(function() {
+          stats.images = Date.now();
+          displayContinuation();
+        });
+      })
     },
 
-
     compile: function(gfx, fonts, images) {
       if (this.code) {
         // content was compiled
@@ -3439,6 +3426,27 @@ var Page = (function() {
       }
       this.code = gfx.compile(content, xref, resources, fonts, images);
     },
+    
+    ensureFonts: function(fonts, callback) {
+      var fontObjs = FontLoader.bind(
+        fonts,
+        function() {
+          // Rebuild the FontsMap. This is emulating the behavior of the main
+          // thread.
+          if (fontObjs) {
+            // Replace the FontsMap hash with the fontObjs.
+            for (var i = 0; i < fontObjs.length; i++) {
+              FontsMap[fontObjs[i].loadedName] = {fontObj: fontObjs[i]};
+            }
+          }
+
+          this.stats.fonts = Date.now();
+          
+          callback.call(this);
+        }.bind(this)
+      );
+    },
+    
     display: function(gfx) {
       assert(this.code instanceof Function,
              'page content must be compiled first');