Merge pull request #21315 from calixteman/issue18548

Keep the first /Subrs and /CharStrings block
This commit is contained in:
calixteman 2026-05-24 18:07:20 +02:00 committed by GitHub
commit 143a7244a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 0 deletions

View File

@ -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") {

View File

@ -922,3 +922,4 @@
!knockout_groups_test.pdf
!issue18032.pdf
!Embedded_font.pdf
!issue18548_reduced.pdf

Binary file not shown.

View File

@ -14303,5 +14303,12 @@
"md5": "b68dd5a3e6833d1af94e295fe1d60285",
"rounds": 1,
"type": "eq"
},
{
"id": "issue18548_reduced",
"file": "pdfs/issue18548_reduced.pdf",
"md5": "39d15f7f810bd89a4e5858df9c75ca4e",
"rounds": 1,
"type": "eq"
}
]