diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 031e051a4..d9e0b4953 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1212,37 +1212,30 @@ class PartialEvaluator { fontRef = fontRes.getRaw(fontName); } } - if (!fontRef) { - const partialMsg = `Font "${ - fontName || (font && font.toString()) - }" is not available`; - - if (!this.options.ignoreErrors && !this.parsingType3Font) { - warn(`${partialMsg}.`); + if (fontRef) { + if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) { return errorFont(); } - warn(`${partialMsg} -- attempting to fallback to a default font.`); + + if (this.fontCache.has(fontRef)) { + return this.fontCache.get(fontRef); + } + + font = xref.fetchIfRef(fontRef); + } + + if (!(font instanceof Dict)) { + if (!this.options.ignoreErrors && !this.parsingType3Font) { + warn(`Font "${fontName}" is not available.`); + return errorFont(); + } + warn( + `Font "${fontName}" is not available -- attempting to fallback to a default font.` + ); // Falling back to a default font to avoid completely broken rendering, // but note that there're no guarantees that things will look "correct". - if (fallbackFontDict) { - fontRef = fallbackFontDict; - } else { - fontRef = PartialEvaluator.fallbackFontDict; - } - } - - if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) { - return errorFont(); - } - - if (this.fontCache.has(fontRef)) { - return this.fontCache.get(fontRef); - } - - font = xref.fetchIfRef(fontRef); - if (!(font instanceof Dict)) { - return errorFont(); + font = fallbackFontDict || PartialEvaluator.fallbackFontDict; } // We are holding `font.cacheKey` references only for `fontRef`s that @@ -4412,7 +4405,7 @@ class PartialEvaluator { static get fallbackFontDict() { const dict = new Dict(); - dict.set("BaseFont", Name.get("PDFJS-FallbackFont")); + dict.set("BaseFont", Name.get("Helvetica")); dict.set("Type", Name.get("FallbackType")); dict.set("Subtype", Name.get("FallbackType")); dict.set("Encoding", Name.get("WinAnsiEncoding")); diff --git a/test/pdfs/issue16432.pdf.link b/test/pdfs/issue16432.pdf.link new file mode 100644 index 000000000..91da7bc8f --- /dev/null +++ b/test/pdfs/issue16432.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/11493613/inputFields-Flattened-Output.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 8951d3d23..3af5133cc 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -50,6 +50,14 @@ "lastPage": 3, "type": "eq" }, + { "id": "issue16432", + "file": "pdfs/issue16432.pdf", + "md5": "b67b0324c307d8af43d11b0edec88e3e", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "eq" + }, { "id": "tracemonkey-fbf", "file": "pdfs/tracemonkey.pdf", "md5": "9a192d8b1a7dc652a19835f6f08098bd",