Fix loading of fonts with invalid encoding name entry (bug 859204 and 878112)

This commit is contained in:
Jonas Jenwald 2014-01-21 01:44:46 +01:00
parent ac91047f6d
commit 575bdd8863
4 changed files with 19 additions and 1 deletions

View File

@ -858,7 +858,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} else if (isName(encoding)) {
overridableEncoding = false;
hasEncoding = true;
baseEncoding = Encodings[encoding.name];
var currentEncoding = Encodings[encoding.name];
// Some bad PDF files contain fonts whose encoding name is not among
// the predefined encodings, causing baseEncoding to be undefined.
// In this case, fallback to using the baseEncoding as defined above
// and let the font override the encoding if one is available.
if (currentEncoding) {
baseEncoding = currentEncoding;
} else {
overridableEncoding = true;
}
} else {
error('Encoding is not a Name nor a Dict');
}

View File

@ -64,3 +64,4 @@
!issue2956.pdf
!bug946506.pdf
!issue3885.pdf
!bug859204.pdf

BIN
test/pdfs/bug859204.pdf Normal file

Binary file not shown.

View File

@ -172,6 +172,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "bug859204",
"file": "pdfs/bug859204.pdf",
"md5": "ac1ea1dbfa6ac9d5b13167483049af0b",
"link": false,
"rounds": 1,
"type": "eq"
},
{ "id": "issue1512",
"file": "pdfs/issue1512.pdf",
"md5": "41a19fe03d522346ee3baa732403fca4",