Skip to content

Commit

Permalink
Merge pull request mozilla#18119 from Snuffleupagus/issue-18117
Browse files Browse the repository at this point in the history
Support charCodes larger than 32-bit in `adjustMapping` (issue 18117)
  • Loading branch information
Snuffleupagus committed May 20, 2024
2 parents 63b66b4 + 440b4b6 commit db7e68a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) {
const isInPrivateArea = code =>
(PRIVATE_USE_AREAS[0][0] <= code && code <= PRIVATE_USE_AREAS[0][1]) ||
(PRIVATE_USE_AREAS[1][0] <= code && code <= PRIVATE_USE_AREAS[1][1]);
for (let originalCharCode in charCodeToGlyphId) {
originalCharCode |= 0;
for (const originalCharCode in charCodeToGlyphId) {
let glyphId = charCodeToGlyphId[originalCharCode];
// For missing glyphs don't create the mappings so the glyph isn't
// drawn.
Expand Down Expand Up @@ -2834,7 +2833,7 @@ class Font {
data: createPostTable(properties),
};

const charCodeToGlyphId = [];
const charCodeToGlyphId = Object.create(null);

// Helper function to try to skip mapping of empty glyphs.
function hasGlyph(glyphId) {
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
!ContentStreamNoCycleType3insideType3.pdf
!ContentStreamCycleType3insideType3.pdf
!issue2074.pdf
!issue18117.pdf
!scan-bad.pdf
!issue13561_reduced.pdf
!bug847420.pdf
Expand Down
Binary file added test/pdfs/issue18117.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5406,6 +5406,20 @@
"lastPage": 2,
"type": "eq"
},
{
"id": "issue18117",
"file": "pdfs/issue18117.pdf",
"md5": "0be6391f9910d807a0ded5e6913ff7e3",
"rounds": 1,
"type": "eq"
},
{
"id": "issue18117-text",
"file": "pdfs/issue18117.pdf",
"md5": "0be6391f9910d807a0ded5e6913ff7e3",
"rounds": 1,
"type": "text"
},
{
"id": "issue4890",
"file": "pdfs/issue4890.pdf",
Expand Down

0 comments on commit db7e68a

Please sign in to comment.