1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #17810 from calixteman/issue17808

Don't translate char codes when platform,encoding isn't (3,0)
This commit is contained in:
calixteman 2024-04-03 17:05:14 +02:00 committed by GitHub
commit d8331e3100
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 9 deletions

View file

@ -2955,10 +2955,7 @@ class Font {
// Always prefer the BaseEncoding/Differences arrays, when they exist
// (fixes issue13433.pdf).
forcePostTable = true;
} else {
// When there is only a (1, 0) cmap table, the char code is a single
// byte and it is used directly as the char code.
} else if (cmapPlatformId === 3 && cmapEncodingId === 0) {
// When a (3, 0) cmap table is present, it is used instead but the
// spec has special rules for char codes in the range of 0xF000 to
// 0xF0FF and it says the (3, 0) table should map the values from
@ -2969,15 +2966,17 @@ class Font {
// cmap.
for (const mapping of cmapMappings) {
let charCode = mapping.charCode;
if (
cmapPlatformId === 3 &&
charCode >= 0xf000 &&
charCode <= 0xf0ff
) {
if (charCode >= 0xf000 && charCode <= 0xf0ff) {
charCode &= 0xff;
}
charCodeToGlyphId[charCode] = mapping.glyphId;
}
} else {
// When there is only a (1, 0) cmap table, the char code is a single
// byte and it is used directly as the char code.
for (const mapping of cmapMappings) {
charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
}
}
// Last, try to map any missing charcodes using the post table.

View file

@ -636,3 +636,4 @@
!bug1868759.pdf
!issue17730.pdf
!bug1883609.pdf
!issue17808.pdf

BIN
test/pdfs/issue17808.pdf Executable file

Binary file not shown.

View file

@ -9794,5 +9794,12 @@
"rounds": 1,
"link": true,
"type": "other"
},
{
"id": "issue17808",
"file": "pdfs/issue17808.pdf",
"md5": "dd66194bdaa0f62bc96c760384f2e098",
"rounds": 1,
"type": "eq"
}
]