mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
Move font translation to the worker
This commit is contained in:
parent
c9684dba32
commit
9fba150dd2
3 changed files with 37 additions and 29 deletions
|
@ -171,31 +171,30 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
|
||||
++self.objIdCounter;
|
||||
if (!font.loadedName) {
|
||||
font.translated = self.translateFont(font, xref, resources,
|
||||
dependency);
|
||||
if (font.translated) {
|
||||
var translated = self.translateFont(font, xref, resources,
|
||||
dependency);
|
||||
if (translated) {
|
||||
// keep track of each font we translated so the caller can
|
||||
// load them asynchronously before calling display on a page
|
||||
loadedName = 'font_' + uniquePrefix + self.objIdCounter;
|
||||
font.translated.properties.loadedName = loadedName;
|
||||
translated.properties.loadedName = loadedName;
|
||||
font.loadedName = loadedName;
|
||||
font.translated = translated;
|
||||
|
||||
var translated = font.translated;
|
||||
// Convert the file to an ArrayBuffer which will be turned back into
|
||||
// a Stream in the main thread.
|
||||
if (translated.file)
|
||||
translated.file = translated.file.getBytes();
|
||||
if (translated.properties.file) {
|
||||
translated.properties.file =
|
||||
translated.properties.file.getBytes();
|
||||
var data;
|
||||
try {
|
||||
var fontObj = new Font(translated.name,
|
||||
translated.file,
|
||||
translated.properties);
|
||||
data = fontObj.export();
|
||||
} catch (e) {
|
||||
data = { error: e };
|
||||
}
|
||||
|
||||
handler.send('obj', [
|
||||
loadedName,
|
||||
'Font',
|
||||
translated.name,
|
||||
translated.file,
|
||||
translated.properties
|
||||
data
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue