diff --git a/src/core/type1_parser.js b/src/core/type1_parser.js index 96343fbe8..843e671ad 100644 --- a/src/core/type1_parser.js +++ b/src/core/type1_parser.js @@ -566,6 +566,13 @@ class Type1Parser { }, }; let token, length, data, lenIV; + // Some fonts (e.g. those embedded in issue18548.pdf) define a second + // `/Subrs` and `/CharStrings` block that the PostScript runtime selects + // conditionally (e.g. high-resolution variants). Testing with other + // viewers shows that none of them actually use these conditional blocks, + // so we can "safely" ignore them. + let subrsParsed = false; + let charStringsParsed = false; while ((token = this.getToken()) !== null) { if (token !== "/") { continue; @@ -573,6 +580,10 @@ class Type1Parser { token = this.getToken(); switch (token) { case "CharStrings": + if (charStringsParsed) { + break; + } + charStringsParsed = true; // The number immediately following CharStrings must be greater or // equal to the number of CharStrings. this.getToken(); @@ -610,6 +621,10 @@ class Type1Parser { } break; case "Subrs": + if (subrsParsed) { + break; + } + subrsParsed = true; this.readInt(); // num this.getToken(); // read in 'array' while (this.getToken() === "dup") { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index bc6027dc6..16ebf27c2 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -922,3 +922,4 @@ !knockout_groups_test.pdf !issue18032.pdf !Embedded_font.pdf +!issue18548_reduced.pdf diff --git a/test/pdfs/issue18548_reduced.pdf b/test/pdfs/issue18548_reduced.pdf new file mode 100644 index 000000000..b38274d7c Binary files /dev/null and b/test/pdfs/issue18548_reduced.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index e3d03daa3..9e3ec7d87 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -14267,5 +14267,12 @@ "md5": "b68dd5a3e6833d1af94e295fe1d60285", "rounds": 1, "type": "eq" + }, + { + "id": "issue18548_reduced", + "file": "pdfs/issue18548_reduced.pdf", + "md5": "39d15f7f810bd89a4e5858df9c75ca4e", + "rounds": 1, + "type": "eq" } ]