Merge pull request #12478 from Snuffleupagus/async-translateFont
Convert `PartialEvaluator.translateFont` to an `async` method
This commit is contained in:
commit
b710fbcb00
@ -1111,15 +1111,7 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
font.translated = fontCapability.promise;
|
font.translated = fontCapability.promise;
|
||||||
|
|
||||||
// TODO move promises into translate font
|
this.translateFont(preEvaluatedFont)
|
||||||
var translatedPromise;
|
|
||||||
try {
|
|
||||||
translatedPromise = this.translateFont(preEvaluatedFont);
|
|
||||||
} catch (e) {
|
|
||||||
translatedPromise = Promise.reject(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
translatedPromise
|
|
||||||
.then(translatedFont => {
|
.then(translatedFont => {
|
||||||
if (translatedFont.fontType !== undefined) {
|
if (translatedFont.fontType !== undefined) {
|
||||||
var xrefFontStats = xref.stats.fontTypes;
|
var xrefFontStats = xref.stats.fontTypes;
|
||||||
@ -3320,7 +3312,7 @@ class PartialEvaluator {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
translateFont(preEvaluatedFont) {
|
async translateFont(preEvaluatedFont) {
|
||||||
var baseDict = preEvaluatedFont.baseDict;
|
var baseDict = preEvaluatedFont.baseDict;
|
||||||
var dict = preEvaluatedFont.dict;
|
var dict = preEvaluatedFont.dict;
|
||||||
var composite = preEvaluatedFont.composite;
|
var composite = preEvaluatedFont.composite;
|
||||||
@ -3465,36 +3457,30 @@ class PartialEvaluator {
|
|||||||
isType3Font: false,
|
isType3Font: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
var cMapPromise;
|
|
||||||
if (composite) {
|
if (composite) {
|
||||||
var cidEncoding = baseDict.get("Encoding");
|
const cidEncoding = baseDict.get("Encoding");
|
||||||
if (isName(cidEncoding)) {
|
if (isName(cidEncoding)) {
|
||||||
properties.cidEncoding = cidEncoding.name;
|
properties.cidEncoding = cidEncoding.name;
|
||||||
}
|
}
|
||||||
cMapPromise = CMapFactory.create({
|
const cMap = await CMapFactory.create({
|
||||||
encoding: cidEncoding,
|
encoding: cidEncoding,
|
||||||
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
||||||
useCMap: null,
|
useCMap: null,
|
||||||
}).then(function (cMap) {
|
|
||||||
properties.cMap = cMap;
|
|
||||||
properties.vertical = properties.cMap.vertical;
|
|
||||||
});
|
});
|
||||||
} else {
|
properties.cMap = cMap;
|
||||||
cMapPromise = Promise.resolve(undefined);
|
properties.vertical = properties.cMap.vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cMapPromise
|
return this.extractDataStructures(dict, baseDict, properties).then(
|
||||||
.then(() => {
|
newProperties => {
|
||||||
return this.extractDataStructures(dict, baseDict, properties);
|
|
||||||
})
|
|
||||||
.then(newProperties => {
|
|
||||||
this.extractWidths(dict, descriptor, newProperties);
|
this.extractWidths(dict, descriptor, newProperties);
|
||||||
|
|
||||||
if (type === "Type3") {
|
if (type === "Type3") {
|
||||||
newProperties.isType3Font = true;
|
newProperties.isType3Font = true;
|
||||||
}
|
}
|
||||||
return new Font(fontName.name, fontFile, newProperties);
|
return new Font(fontName.name, fontFile, newProperties);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static buildFontPaths(font, glyphs, handler) {
|
static buildFontPaths(font, glyphs, handler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user