From ce52ce063ec181e9c2138aa4b0ef162417eed177 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 25 May 2024 10:46:12 +0200 Subject: [PATCH] Change `parsingType3Font` to a getter (PR 14448 follow-up) We can easily "compute" `parsingType3Font` from the `type3FontRefs`-value, and thus avoid having to separately track two related properties. --- src/core/evaluator.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 1ed1c3749..5e31d0d92 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -224,7 +224,7 @@ class PartialEvaluator { this.globalImageCache = globalImageCache; this.systemFontCache = systemFontCache; this.options = options || DefaultPartialEvaluatorOptions; - this.parsingType3Font = false; + this.type3FontRefs = null; this._regionalImageCache = new RegionalImageCache(); this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this); @@ -243,6 +243,10 @@ class PartialEvaluator { return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory); } + get parsingType3Font() { + return !!this.type3FontRefs; + } + clone(newOptions = null) { const newEvaluator = Object.create(this); newEvaluator.options = Object.assign( @@ -1253,7 +1257,7 @@ class PartialEvaluator { } } if (fontRef) { - if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) { + if (this.type3FontRefs?.has(fontRef)) { return errorFont(); } @@ -4633,7 +4637,6 @@ class TranslatedFont { // Compared to the parsing of e.g. an entire page, it doesn't really // make sense to only be able to render a Type3 glyph partially. const type3Evaluator = evaluator.clone({ ignoreErrors: false }); - type3Evaluator.parsingType3Font = true; // Prevent circular references in Type3 fonts. const type3FontRefs = new RefSet(evaluator.type3FontRefs); if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) {