From d1bef8cb8660a5da1e250ed4888c3b8f7779bd4a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 21 Jan 2024 17:36:50 +0100 Subject: [PATCH] Use `await` consistently in the `PartialEvaluator.translateFont` method --- src/core/evaluator.js | 54 ++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 3673df23f..e0e9ea85a 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -4169,7 +4169,6 @@ class PartialEvaluator { cssFontInfo, }) { const isType3Font = type === "Type3"; - let properties; if (!descriptor) { if (isType3Font) { @@ -4200,7 +4199,7 @@ class PartialEvaluator { ? FontFlags.Symbolic : FontFlags.Nonsymbolic); - properties = { + const properties = { type, name: baseFontName, loadedName: baseDict.loadedName, @@ -4234,24 +4233,26 @@ class PartialEvaluator { standardFontName ); } - return this.extractDataStructures(dict, dict, properties).then( - newProperties => { - if (widths) { - const glyphWidths = []; - let j = firstChar; - for (const width of widths) { - glyphWidths[j++] = this.xref.fetchIfRef(width); - } - newProperties.widths = glyphWidths; - } else { - newProperties.widths = this.buildCharCodeToWidth( - metrics.widths, - newProperties - ); - } - return new Font(baseFontName, file, newProperties); - } + + const newProperties = await this.extractDataStructures( + dict, + dict, + properties ); + if (widths) { + const glyphWidths = []; + let j = firstChar; + for (const width of widths) { + glyphWidths[j++] = this.xref.fetchIfRef(width); + } + newProperties.widths = glyphWidths; + } else { + newProperties.widths = this.buildCharCodeToWidth( + metrics.widths, + newProperties + ); + } + return new Font(baseFontName, file, newProperties); } } @@ -4355,7 +4356,7 @@ class PartialEvaluator { } } - properties = { + const properties = { type, name: fontName.name, subtype, @@ -4398,13 +4399,14 @@ class PartialEvaluator { properties.vertical = properties.cMap.vertical; } - return this.extractDataStructures(dict, baseDict, properties).then( - newProperties => { - this.extractWidths(dict, descriptor, newProperties); - - return new Font(fontName.name, fontFile, newProperties); - } + const newProperties = await this.extractDataStructures( + dict, + baseDict, + properties ); + this.extractWidths(dict, descriptor, newProperties); + + return new Font(fontName.name, fontFile, newProperties); } static buildFontPaths(font, glyphs, handler, evaluatorOptions) {