Convert the handleSetFont
methods, in src/core/evaluator.js
, to be async
This commit is contained in:
parent
fce822cde0
commit
fc62eec901
@ -1007,7 +1007,7 @@ class PartialEvaluator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSetFont(
|
async handleSetFont(
|
||||||
resources,
|
resources,
|
||||||
fontArgs,
|
fontArgs,
|
||||||
fontRef,
|
fontRef,
|
||||||
@ -1019,41 +1019,33 @@ class PartialEvaluator {
|
|||||||
) {
|
) {
|
||||||
const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null;
|
const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null;
|
||||||
|
|
||||||
return this.loadFont(
|
let translated = await this.loadFont(
|
||||||
fontName,
|
fontName,
|
||||||
fontRef,
|
fontRef,
|
||||||
resources,
|
resources,
|
||||||
fallbackFontDict,
|
fallbackFontDict,
|
||||||
cssFontInfo
|
cssFontInfo
|
||||||
)
|
);
|
||||||
.then(translated => {
|
|
||||||
if (!translated.font.isType3Font) {
|
if (translated.font.isType3Font) {
|
||||||
return translated;
|
try {
|
||||||
}
|
await translated.loadType3Data(this, resources, task);
|
||||||
return translated
|
|
||||||
.loadType3Data(this, resources, task)
|
|
||||||
.then(function () {
|
|
||||||
// Add the dependencies to the parent operatorList so they are
|
// Add the dependencies to the parent operatorList so they are
|
||||||
// resolved before Type3 operatorLists are executed synchronously.
|
// resolved before Type3 operatorLists are executed synchronously.
|
||||||
operatorList.addDependencies(translated.type3Dependencies);
|
operatorList.addDependencies(translated.type3Dependencies);
|
||||||
|
} catch (reason) {
|
||||||
return translated;
|
translated = new TranslatedFont({
|
||||||
})
|
|
||||||
.catch(
|
|
||||||
reason =>
|
|
||||||
new TranslatedFont({
|
|
||||||
loadedName: "g_font_error",
|
loadedName: "g_font_error",
|
||||||
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
||||||
dict: translated.font,
|
dict: translated.font,
|
||||||
evaluatorOptions: this.options,
|
evaluatorOptions: this.options,
|
||||||
})
|
});
|
||||||
);
|
}
|
||||||
})
|
}
|
||||||
.then(translated => {
|
|
||||||
state.font = translated.font;
|
state.font = translated.font;
|
||||||
translated.send(this.handler);
|
translated.send(this.handler);
|
||||||
return translated.loadedName;
|
return translated.loadedName;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleText(chars, state) {
|
handleText(chars, state) {
|
||||||
@ -2560,29 +2552,21 @@ class PartialEvaluator {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSetFont(fontName, fontRef) {
|
async function handleSetFont(fontName, fontRef) {
|
||||||
return self
|
const translated = await self.loadFont(fontName, fontRef, resources);
|
||||||
.loadFont(fontName, fontRef, resources)
|
|
||||||
.then(function (translated) {
|
if (translated.font.isType3Font) {
|
||||||
if (!translated.font.isType3Font) {
|
try {
|
||||||
return translated;
|
await translated.loadType3Data(self, resources, task);
|
||||||
}
|
} catch {
|
||||||
return translated
|
|
||||||
.loadType3Data(self, resources, task)
|
|
||||||
.catch(function () {
|
|
||||||
// Ignore Type3-parsing errors, since we only use `loadType3Data`
|
// Ignore Type3-parsing errors, since we only use `loadType3Data`
|
||||||
// here to ensure that we'll always obtain a useful /FontBBox.
|
// here to ensure that we'll always obtain a useful /FontBBox.
|
||||||
})
|
}
|
||||||
.then(function () {
|
}
|
||||||
return translated;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(function (translated) {
|
|
||||||
textState.loadedName = translated.loadedName;
|
textState.loadedName = translated.loadedName;
|
||||||
textState.font = translated.font;
|
textState.font = translated.font;
|
||||||
textState.fontMatrix =
|
textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
|
||||||
translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyInverseRotation(x, y, matrix) {
|
function applyInverseRotation(x, y, matrix) {
|
||||||
|
Loading…
Reference in New Issue
Block a user