From acd61a138efe2fc900537322d6f57f73c8d03029 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 15 Jul 2022 13:32:08 +0200 Subject: [PATCH] Handle errors in the "Loading by ref" code-path in `PartialEvaluator.loadFont` Note how we currently throw a "raw" Error, which is problematical since all of the `PartialEvaluator.loadFont` call-sites expect a Promise to be returned. Furthermore, this also means that we don't benefit from the fallback code-path that now exists below. *Please note:* Unfortunately I don't have a test-case that fails without this patch, since it's something I happened to notice when reading the code while working on another patch. --- src/core/evaluator.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index a6ebd12b1869f..213e9b4c1a593 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1176,10 +1176,9 @@ class PartialEvaluator { let fontRef; if (font) { // Loading by ref. - if (!(font instanceof Ref)) { - throw new FormatError('The "font" object should be a reference.'); + if (font instanceof Ref) { + fontRef = font; } - fontRef = font; } else { // Loading by name. const fontRes = resources.get("Font");