mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Don't translate char codes when platform,encoding isn't (3,0)
This commit is contained in:
parent
2e5282928f
commit
8f5d907a52
4 changed files with 16 additions and 9 deletions
|
@ -2955,10 +2955,7 @@ class Font {
|
||||||
// Always prefer the BaseEncoding/Differences arrays, when they exist
|
// Always prefer the BaseEncoding/Differences arrays, when they exist
|
||||||
// (fixes issue13433.pdf).
|
// (fixes issue13433.pdf).
|
||||||
forcePostTable = true;
|
forcePostTable = true;
|
||||||
} else {
|
} else if (cmapPlatformId === 3 && cmapEncodingId === 0) {
|
||||||
// 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.
|
|
||||||
|
|
||||||
// When a (3, 0) cmap table is present, it is used instead but the
|
// 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
|
// 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
|
// 0xF0FF and it says the (3, 0) table should map the values from
|
||||||
|
@ -2969,15 +2966,17 @@ class Font {
|
||||||
// cmap.
|
// cmap.
|
||||||
for (const mapping of cmapMappings) {
|
for (const mapping of cmapMappings) {
|
||||||
let charCode = mapping.charCode;
|
let charCode = mapping.charCode;
|
||||||
if (
|
if (charCode >= 0xf000 && charCode <= 0xf0ff) {
|
||||||
cmapPlatformId === 3 &&
|
|
||||||
charCode >= 0xf000 &&
|
|
||||||
charCode <= 0xf0ff
|
|
||||||
) {
|
|
||||||
charCode &= 0xff;
|
charCode &= 0xff;
|
||||||
}
|
}
|
||||||
charCodeToGlyphId[charCode] = mapping.glyphId;
|
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.
|
// Last, try to map any missing charcodes using the post table.
|
||||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -636,3 +636,4 @@
|
||||||
!bug1868759.pdf
|
!bug1868759.pdf
|
||||||
!issue17730.pdf
|
!issue17730.pdf
|
||||||
!bug1883609.pdf
|
!bug1883609.pdf
|
||||||
|
!issue17808.pdf
|
||||||
|
|
BIN
test/pdfs/issue17808.pdf
Executable file
BIN
test/pdfs/issue17808.pdf
Executable file
Binary file not shown.
|
@ -9794,5 +9794,12 @@
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "other"
|
"type": "other"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue17808",
|
||||||
|
"file": "pdfs/issue17808.pdf",
|
||||||
|
"md5": "dd66194bdaa0f62bc96c760384f2e098",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue