Skip to content

Commit

Permalink
Merge pull request #17674 from calixteman/issue17671
Browse files Browse the repository at this point in the history
Fix the endoffset of the last glyph when it's followed by a null offset in the loca table
  • Loading branch information
calixteman authored Feb 15, 2024
2 parents dbda3ec + fcad371 commit a83a8d7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,14 @@ class Font {
break;
}

// If the last offset is 0 in the loca table then we can't compute the
// endOffset for the last glyph. So in such a case we set the endOffset
// to the end of the data (fixes issue #17671).
const last = locaEntries.at(-2);
if (last.offset !== 0 && last.endOffset === 0) {
last.endOffset = oldGlyfDataLength;
}

const missingGlyphs = Object.create(null);
let writeOffset = 0;
itemEncode(locaData, 0, writeOffset);
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,4 @@
!issue17492.pdf
!issue17540.pdf
!bug1669097.pdf
!issue17671.pdf
Binary file added test/pdfs/issue17671.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9675,5 +9675,12 @@
"id": null
}
}
},
{
"id": "issue17671",
"file": "pdfs/issue17671.pdf",
"md5": "407695b36b4611bc7c501a891c8a4b28",
"rounds": 1,
"type": "eq"
}
]

0 comments on commit a83a8d7

Please sign in to comment.