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.
This commit is contained in:
Jonas Jenwald 2022-07-15 13:32:08 +02:00
parent 3256761ead
commit acd61a138e

View File

@ -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");