Ignore invalid /CIDToGIDMap-entries when parsing fonts (issue 15139)

In the referenced PDF document the fonts have /CIDToGIDMap-entries that cannot be loaded. Hence, only when `ignoreErrors` is set, we'll now ignore these corrupt /CIDToGIDMap-entries and fallback to simply assume that no such data is available.

Given that this is *clearly* a case of a corrupt PDF document, there's no guarantee that this will "fix" things in the general case since a /CIDToGIDMap may be *required* in order for some composite fonts to render correctly. However, attempting to render *something* is surely better than skipping a font altogether.
This commit is contained in:
Jonas Jenwald 2022-07-13 10:06:16 +02:00
parent 7a4b72ed11
commit 60bd9580e2
3 changed files with 19 additions and 3 deletions

View File

@ -3373,9 +3373,16 @@ class PartialEvaluator {
};
}
const cidToGidMap = dict.get("CIDToGIDMap");
if (cidToGidMap instanceof BaseStream) {
cidToGidBytes = cidToGidMap.getBytes();
try {
const cidToGidMap = dict.get("CIDToGIDMap");
if (cidToGidMap instanceof BaseStream) {
cidToGidBytes = cidToGidMap.getBytes();
}
} catch (ex) {
if (!this.options.ignoreErrors) {
throw ex;
}
warn(`extractDataStructures - ignoring CIDToGIDMap data: "${ex}".`);
}
}

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/9137443/sample4a.pdf

View File

@ -4980,6 +4980,14 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "issue15139",
"file": "pdfs/issue15139.pdf",
"md5": "0f2beb6a788d1e47bb9af737f6670493",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "gesamt",
"file": "pdfs/gesamt.pdf",
"md5": "743aaa6f46ed0a42864f079d632d942e",