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,
|
normalizeWhitespace = false,
|
||||||
combineTextItems = false,
|
combineTextItems = false,
|
||||||
sink,
|
sink,
|
||||||
seenStyles = Object.create(null),
|
seenStyles = new Set(),
|
||||||
}) {
|
}) {
|
||||||
// Ensure that `resources`/`stateManager` is correctly initialized,
|
// Ensure that `resources`/`stateManager` is correctly initialized,
|
||||||
// even if the provided parameter is e.g. `null`.
|
// even if the provided parameter is e.g. `null`.
|
||||||
@ -2024,17 +2024,19 @@ class PartialEvaluator {
|
|||||||
if (textContentItem.initialized) {
|
if (textContentItem.initialized) {
|
||||||
return textContentItem;
|
return textContentItem;
|
||||||
}
|
}
|
||||||
var font = textState.font;
|
const font = textState.font,
|
||||||
if (!(font.loadedName in seenStyles)) {
|
loadedName = font.loadedName;
|
||||||
seenStyles[font.loadedName] = true;
|
if (!seenStyles.has(loadedName)) {
|
||||||
textContent.styles[font.loadedName] = {
|
seenStyles.add(loadedName);
|
||||||
|
|
||||||
|
textContent.styles[loadedName] = {
|
||||||
fontFamily: font.fallbackName,
|
fontFamily: font.fallbackName,
|
||||||
ascent: font.ascent,
|
ascent: font.ascent,
|
||||||
descent: font.descent,
|
descent: font.descent,
|
||||||
vertical: font.vertical,
|
vertical: font.vertical,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
textContentItem.fontName = font.loadedName;
|
textContentItem.fontName = loadedName;
|
||||||
|
|
||||||
// 9.4.4 Text Space Details
|
// 9.4.4 Text Space Details
|
||||||
var tsm = [
|
var tsm = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user