Set loadedName in Partial Eval
This commit is contained in:
parent
e9f4a3d8ee
commit
2c51c6fb9e
14
fonts.js
14
fonts.js
@ -472,16 +472,18 @@ var Font = (function Font() {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
this.type = properties.type;
|
this.type = properties.type;
|
||||||
this.textMatrix = properties.textMatrix;
|
this.textMatrix = properties.textMatrix;
|
||||||
this.loadedName = getUniqueName();
|
|
||||||
this.composite = properties.composite;
|
this.composite = properties.composite;
|
||||||
|
this.loadedName = properties.loadedName;
|
||||||
|
|
||||||
|
// TODO: Remove this once we can be sure nothing got broken to du changes
|
||||||
|
// in this commit.
|
||||||
|
if (!this.loadedName) {
|
||||||
|
throw "There has to be a `loadedName`";
|
||||||
|
}
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var numFonts = 0;
|
|
||||||
function getUniqueName() {
|
|
||||||
return 'pdfFont' + numFonts++;
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringToArray(str) {
|
function stringToArray(str) {
|
||||||
var array = [];
|
var array = [];
|
||||||
for (var i = 0; i < str.length; ++i)
|
for (var i = 0; i < str.length; ++i)
|
||||||
|
64
pdf.js
64
pdf.js
@ -3373,28 +3373,51 @@ var Page = (function() {
|
|||||||
// Firefox error reporting from XHR callbacks.
|
// Firefox error reporting from XHR callbacks.
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var exc = null;
|
var exc = null;
|
||||||
try {
|
// try {
|
||||||
self.display(gfx);
|
self.display(gfx);
|
||||||
stats.render = Date.now();
|
stats.render = Date.now();
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
exc = e.toString();
|
// exc = e.toString();
|
||||||
}
|
// }
|
||||||
if (continuation) continuation(exc);
|
continuation(exc);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Make a copy of the necessary datat to build a font later. The `font`
|
||||||
|
// object will be sent to the main thread later on.
|
||||||
|
var fontsBackup = fonts;
|
||||||
|
fonts = [];
|
||||||
|
for (var i = 0; i < fontsBackup.length; i++) {
|
||||||
|
var orgFont = fontsBackup[i];
|
||||||
|
var orgFontObj = orgFont.fontObj;
|
||||||
|
|
||||||
|
var font = {
|
||||||
|
name: orgFont.name,
|
||||||
|
file: orgFont.file,
|
||||||
|
properties: orgFont.properties
|
||||||
|
}
|
||||||
|
fonts.push(font);
|
||||||
|
}
|
||||||
|
|
||||||
var fontObjs = FontLoader.bind(
|
var fontObjs = FontLoader.bind(
|
||||||
fonts,
|
fonts,
|
||||||
function() {
|
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();
|
stats.fonts = Date.now();
|
||||||
images.notifyOnLoad(function() {
|
images.notifyOnLoad(function() {
|
||||||
stats.images = Date.now();
|
stats.images = Date.now();
|
||||||
displayContinuation();
|
displayContinuation();
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
for (var i = 0, ii = fonts.length; i < ii; ++i)
|
|
||||||
fonts[i].dict.fontObj = fontObjs[i];
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -4052,6 +4075,7 @@ var EvalState = (function() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
var FontsMap = {};
|
var FontsMap = {};
|
||||||
|
var FontLoadedCounter = 0;
|
||||||
|
|
||||||
var PartialEvaluator = (function() {
|
var PartialEvaluator = (function() {
|
||||||
function constructor() {
|
function constructor() {
|
||||||
@ -4157,7 +4181,9 @@ var PartialEvaluator = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
evaluate: function(stream, xref, resources, fonts, images) {
|
evalRaw: function(stream, xref, resources, fonts, images, uniquePrefix) {
|
||||||
|
uniquePrefix = uniquePrefix || "";
|
||||||
|
|
||||||
resources = xref.fetchIfRef(resources) || new Dict();
|
resources = xref.fetchIfRef(resources) || new Dict();
|
||||||
var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict();
|
var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict();
|
||||||
var patterns = xref.fetchIfRef(resources.get('Pattern')) || new Dict();
|
var patterns = xref.fetchIfRef(resources.get('Pattern')) || new Dict();
|
||||||
@ -4223,10 +4249,13 @@ var PartialEvaluator = (function() {
|
|||||||
// keep track of each font we translated so the caller can
|
// keep track of each font we translated so the caller can
|
||||||
// load them asynchronously before calling display on a page
|
// load them asynchronously before calling display on a page
|
||||||
fonts.push(font.translated);
|
fonts.push(font.translated);
|
||||||
FontsMap[font.translated.name] = font;
|
|
||||||
|
var loadedName = uniquePrefix + "font_" + (FontLoadedCounter++);
|
||||||
|
font.translated.properties.loadedName = loadedName;
|
||||||
|
FontsMap[loadedName] = font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args[0].name = font.translated.name;
|
args[0].name = font.translated.properties.loadedName;
|
||||||
} else {
|
} else {
|
||||||
// TODO: TOASK: Is it possible to get here? If so, what does
|
// TODO: TOASK: Is it possible to get here? If so, what does
|
||||||
// args[0].name should be like???
|
// args[0].name should be like???
|
||||||
@ -4246,7 +4275,18 @@ var PartialEvaluator = (function() {
|
|||||||
window.fnArray = fnArray;
|
window.fnArray = fnArray;
|
||||||
window.argsArray = argsArray;
|
window.argsArray = argsArray;
|
||||||
|
|
||||||
|
return {
|
||||||
|
fnArray: fnArray,
|
||||||
|
argsArray: argsArray
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
eval: function(stream, xref, resources, fonts, images, uniquePrefix) {
|
||||||
|
var ret = this.evalRaw(stream, xref, resources, fonts, images, uniquePrefix);
|
||||||
|
|
||||||
return function(gfx) {
|
return function(gfx) {
|
||||||
|
var argsArray = ret.argsArray;
|
||||||
|
var fnArray = ret.fnArray;
|
||||||
for (var i = 0, length = argsArray.length; i < length; i++)
|
for (var i = 0, length = argsArray.length; i < length; i++)
|
||||||
gfx[fnArray[i]].apply(gfx, argsArray[i]);
|
gfx[fnArray[i]].apply(gfx, argsArray[i]);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user