Move ensureFont code part of Page into its own function
This commit is contained in:
parent
0a571899c8
commit
e3dd329739
48
pdf.js
48
pdf.js
@ -3356,6 +3356,7 @@ var Page = (function() {
|
|||||||
}
|
}
|
||||||
return shadow(this, 'rotate', rotate);
|
return shadow(this, 'rotate', rotate);
|
||||||
},
|
},
|
||||||
|
|
||||||
startRendering: function(canvasCtx, continuation) {
|
startRendering: function(canvasCtx, continuation) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var stats = self.stats;
|
var stats = self.stats;
|
||||||
@ -3399,28 +3400,14 @@ var Page = (function() {
|
|||||||
fonts.push(font);
|
fonts.push(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fontObjs = FontLoader.bind(
|
this.ensureFonts(fonts, function() {
|
||||||
fonts,
|
images.notifyOnLoad(function() {
|
||||||
function() {
|
stats.images = Date.now();
|
||||||
// Rebuild the FontsMap. This is emulating the behavior of the main
|
displayContinuation();
|
||||||
// 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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
compile: function(gfx, fonts, images) {
|
compile: function(gfx, fonts, images) {
|
||||||
if (this.code) {
|
if (this.code) {
|
||||||
// content was compiled
|
// content was compiled
|
||||||
@ -3439,6 +3426,27 @@ var Page = (function() {
|
|||||||
}
|
}
|
||||||
this.code = gfx.compile(content, xref, resources, fonts, images);
|
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) {
|
display: function(gfx) {
|
||||||
assert(this.code instanceof Function,
|
assert(this.code instanceof Function,
|
||||||
'page content must be compiled first');
|
'page content must be compiled first');
|
||||||
|
Loading…
Reference in New Issue
Block a user