Merge pull request #16434 from Snuffleupagus/issue-16432
Attempt to fallback to a default font, for non-available ones, in more cases (issue 16432)
This commit is contained in:
commit
46bbabbd5d
@ -1212,37 +1212,30 @@ class PartialEvaluator {
|
|||||||
fontRef = fontRes.getRaw(fontName);
|
fontRef = fontRes.getRaw(fontName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fontRef) {
|
if (fontRef) {
|
||||||
const partialMsg = `Font "${
|
if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) {
|
||||||
fontName || (font && font.toString())
|
|
||||||
}" is not available`;
|
|
||||||
|
|
||||||
if (!this.options.ignoreErrors && !this.parsingType3Font) {
|
|
||||||
warn(`${partialMsg}.`);
|
|
||||||
return errorFont();
|
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,
|
// Falling back to a default font to avoid completely broken rendering,
|
||||||
// but note that there're no guarantees that things will look "correct".
|
// but note that there're no guarantees that things will look "correct".
|
||||||
if (fallbackFontDict) {
|
font = fallbackFontDict || PartialEvaluator.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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are holding `font.cacheKey` references only for `fontRef`s that
|
// We are holding `font.cacheKey` references only for `fontRef`s that
|
||||||
@ -4412,7 +4405,7 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
static get fallbackFontDict() {
|
static get fallbackFontDict() {
|
||||||
const dict = new Dict();
|
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("Type", Name.get("FallbackType"));
|
||||||
dict.set("Subtype", Name.get("FallbackType"));
|
dict.set("Subtype", Name.get("FallbackType"));
|
||||||
dict.set("Encoding", Name.get("WinAnsiEncoding"));
|
dict.set("Encoding", Name.get("WinAnsiEncoding"));
|
||||||
|
1
test/pdfs/issue16432.pdf.link
Normal file
1
test/pdfs/issue16432.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/11493613/inputFields-Flattened-Output.pdf
|
@ -50,6 +50,14 @@
|
|||||||
"lastPage": 3,
|
"lastPage": 3,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue16432",
|
||||||
|
"file": "pdfs/issue16432.pdf",
|
||||||
|
"md5": "b67b0324c307d8af43d11b0edec88e3e",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "tracemonkey-fbf",
|
{ "id": "tracemonkey-fbf",
|
||||||
"file": "pdfs/tracemonkey.pdf",
|
"file": "pdfs/tracemonkey.pdf",
|
||||||
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
|
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
|
||||||
|
Loading…
Reference in New Issue
Block a user