diff --git a/src/evaluator.js b/src/evaluator.js index 1c41f8409..6756c9b64 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -1146,10 +1146,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // a variant. var firstChar = dict.get('FirstChar') || 0; var lastChar = dict.get('LastChar') || maxCharIndex; + var fontName = descriptor.get('FontName'); + var baseFont = baseDict.get('BaseFont'); // Some bad pdf's have a string as the font name. - if (isString(fontName)) + if (isString(fontName)) { fontName = new Name(fontName); + } + if (isString(baseFont)) { + baseFont = new Name(baseFont); + } + + var fontNameStr = fontName && fontName.name; + var baseFontStr = baseFont && baseFont.name; + if (fontNameStr !== baseFontStr) { + warn('The FontDescriptor\'s FontName is "' + fontNameStr + + '" but should be the same as the Font\'s BaseFont "' + + baseFontStr + '"'); + } + fontName = fontName || baseFont; + assertWellFormed(isName(fontName), 'invalid font name'); var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3'); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 32c97bad7..a6a6eac10 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -38,3 +38,4 @@ !mixedfonts.pdf !shading_extend.pdf !noembed-identity.pdf +!issue2099-1.pdf diff --git a/test/pdfs/issue2099-1.pdf b/test/pdfs/issue2099-1.pdf new file mode 100644 index 000000000..987006e7e --- /dev/null +++ b/test/pdfs/issue2099-1.pdf @@ -0,0 +1,137 @@ +%PDF-1.4 +%âãÏÓ +1 0 obj +<< +/Pages 2 0 R +/Metadata 3 0 R +/Type /Catalog +>> +endobj +2 0 obj +<< +/Kids [4 0 R] +/Count 1 +/Type /Pages +>> +endobj +3 0 obj +<< +/Subtype /XML +/Length 1421 +/Type /Metadata +>> +stream + + + + + +2013-01-11T10:57:59-08:00 +2013-01-11T10:57:59-08:00 +GNU Enscript 1.6.6 + +Enscript OutputMack Duan + + + + + +endstream +endobj +4 0 obj +<< +/Rotate 0 +/Parent 2 0 R +/Resources +<< +/ExtGState 5 0 R +/Font 6 0 R +/ProcSet [/PDF /Text] +>> +/MediaBox [0 0 595 842] +/Contents 7 0 R +/Type /Page +>> +endobj +5 0 obj +<< +/R7 8 0 R +>> +endobj +6 0 obj +<< +/R8 9 0 R +>> +endobj +7 0 obj +<< +/Length 138 +>> +stream +q 0.1 0 0 0.1 0 0 cm +/R7 gs +0 g +q +10 0 0 10 0 0 cm BT +/R8 10 Tf +1 0 0 1 29 805 Tm +(test missing FontName in FontDescriptor dict)Tj +ET +Q +Q + +endstream +endobj +8 0 obj +<< +/Type /ExtGState +/OPM 1 +>> +endobj +9 0 obj +<< +/BaseFont /Courier +/Subtype /Type1 +/FontDescriptor 10 0 R +/Type /Font +>> +endobj +10 0 obj +<< +/Type /FontDescriptor +>> +endobj +11 0 obj +<< +/Creator (GNU Enscript 1.6.6) +/Title (Enscript Output) +/Producer (GPL Ghostscript 9.05) +/Author (Mack Duan) +/ModDate (D:20130111105759-08'00') +/CreationDate (D:20130111105759-08'00') +>> +endobj xref +0 12 +0000000000 65535 f +0000000015 00000 n +0000000082 00000 n +0000000141 00000 n +0000001647 00000 n +0000001815 00000 n +0000001848 00000 n +0000001881 00000 n +0000002073 00000 n +0000002120 00000 n +0000002213 00000 n +0000002259 00000 n +trailer + +<< +/Info 11 0 R +/Root 1 0 R +/Size 12 +/ID [<2eee0bd94f14c7014ff602c9df19ad9a> <2eee0bd94f14c7014ff602c9df19ad9a>] +>> +startxref +2465 +%%EOF diff --git a/test/test_manifest.json b/test/test_manifest.json index cf28c369d..2563be202 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -801,5 +801,11 @@ "md5": "05d3803b6c22451e18cb60d8d8c75c0c", "rounds": 1, "type": "eq" + }, + { "id": "issue2099-1", + "file": "pdfs/issue2099-1.pdf", + "md5": "c7eca682d70a976dfc4b7e64d3e9f1ce", + "rounds": 1, + "type": "eq" } ]