diff --git a/src/core/fonts.js b/src/core/fonts.js index 5b107f8e5..f249e229b 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -5205,13 +5205,21 @@ var Type1Parser = (function Type1ParserClosure() { for (var j = 0; j < size; j++) { var token = this.getToken(); - if (token === 'dup') { - var index = this.readInt(); - this.getToken(); // read in '/' - var glyph = this.getToken(); - encoding[index] = glyph; - this.getToken(); // read the in 'put' + // skipping till first dup or def (e.g. ignoring for statement) + while (token !== 'dup' && token !== 'def') { + token = this.getToken(); + if (token === null) { + return; // invalid header + } } + if (token === 'def') { + break; // read all array data + } + var index = this.readInt(); + this.getToken(); // read in '/' + var glyph = this.getToken(); + encoding[index] = glyph; + this.getToken(); // read the in 'put' } } if (properties.overridableEncoding && encoding) { @@ -5219,6 +5227,13 @@ var Type1Parser = (function Type1ParserClosure() { break; } break; + case 'FontBBox': + var fontBBox = this.readNumberArray(); + // adjusting ascent/descent + properties.ascent = fontBBox[3]; + properties.descent = fontBBox[1]; + properties.ascentScaled = true; + break; } } } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 8463dee42..c330cd14a 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -29,6 +29,7 @@ !TAMReview.pdf !issue918.pdf !issue1905.pdf +!issue2833.pdf !rotated.pdf !issue1249.pdf !smaskdim.pdf diff --git a/test/pdfs/issue2833.pdf b/test/pdfs/issue2833.pdf new file mode 100644 index 000000000..7f338ec07 Binary files /dev/null and b/test/pdfs/issue2833.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index b66c4cd98..f6d672911 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -33,6 +33,13 @@ "type": "load", "about": "PDF with undefined stream length." }, + { "id": "issue2833", + "file": "pdfs/issue2833.pdf", + "md5": "7bc6e17c41586155c188d7408bcb9ab5", + "rounds": 1, + "lastPage": 1, + "type": "eq" + }, { "id": "issue2881", "file": "pdfs/issue2881.pdf", "md5": "ea6ade27d2cb146676d23dcd6605d5ee",