From eefc94ceb7443febb4b48b789f0551ba7894efc1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 29 May 2021 20:01:52 +0200 Subject: [PATCH] Ensure that we fully load Type3 fonts in `PartialEvaluator.getTextContent` This is necessary now, since with the previous patch the /FontBBox potentially depends on the contents of the /CharProcs-streams. Note that if `getOperatorList` is called *before* `getTextContent`, this patch doesn't matter since the font is already fully loaded/parsed. However, for e.g. the `text` test-cases this is necessary to ensure correct reference images. --- src/core/evaluator.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index ab8fc66dc..e7705418f 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2251,6 +2251,20 @@ class PartialEvaluator { function handleSetFont(fontName, fontRef) { return self .loadFont(fontName, fontRef, resources) + .then(function (translated) { + if (!translated.font.isType3Font) { + return translated; + } + return translated + .loadType3Data(self, resources, task) + .catch(function () { + // Ignore Type3-parsing errors, since we only use `loadType3Data` + // here to ensure that we'll always obtain a useful /FontBBox. + }) + .then(function () { + return translated; + }); + }) .then(function (translated) { textState.font = translated.font; textState.fontMatrix =