Change the seenStyles
object, in PartialEvaluator.getTextContent
, to a Set
Given that what we actually want is only to keep track of the loadedFont-names, rather than storing any actual data, using an object isn't really necessary here. Furthermore, in the current code, we're also using `in` when checking if the data exists, which is generally less efficient than just checking for the value directly.
This commit is contained in:
parent
5cf116a958
commit
68d3a333ac
@ -1974,7 +1974,7 @@ class PartialEvaluator {
|
||||
normalizeWhitespace = false,
|
||||
combineTextItems = false,
|
||||
sink,
|
||||
seenStyles = Object.create(null),
|
||||
seenStyles = new Set(),
|
||||
}) {
|
||||
// Ensure that `resources`/`stateManager` is correctly initialized,
|
||||
// even if the provided parameter is e.g. `null`.
|
||||
@ -2024,17 +2024,19 @@ class PartialEvaluator {
|
||||
if (textContentItem.initialized) {
|
||||
return textContentItem;
|
||||
}
|
||||
var font = textState.font;
|
||||
if (!(font.loadedName in seenStyles)) {
|
||||
seenStyles[font.loadedName] = true;
|
||||
textContent.styles[font.loadedName] = {
|
||||
const font = textState.font,
|
||||
loadedName = font.loadedName;
|
||||
if (!seenStyles.has(loadedName)) {
|
||||
seenStyles.add(loadedName);
|
||||
|
||||
textContent.styles[loadedName] = {
|
||||
fontFamily: font.fallbackName,
|
||||
ascent: font.ascent,
|
||||
descent: font.descent,
|
||||
vertical: font.vertical,
|
||||
};
|
||||
}
|
||||
textContentItem.fontName = font.loadedName;
|
||||
textContentItem.fontName = loadedName;
|
||||
|
||||
// 9.4.4 Text Space Details
|
||||
var tsm = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user