mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Support multi-byte ToUnicode entries, when using predefined CMaps (issue 16176)
Hopefully this makes sense, since we already "create" multi-byte ToUnicode entries in other cases (see e.g. the `getNormalizedUnicodes` table).
This commit is contained in:
parent
b1e0253f29
commit
d4bcfe8c16
4 changed files with 27 additions and 4 deletions
|
@ -3632,7 +3632,8 @@ class PartialEvaluator {
|
|||
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
||||
useCMap: null,
|
||||
});
|
||||
const toUnicode = [];
|
||||
const toUnicode = [],
|
||||
buf = [];
|
||||
properties.cMap.forEach(function (charcode, cid) {
|
||||
if (cid > 0xffff) {
|
||||
throw new FormatError("Max size of CID is 65,535");
|
||||
|
@ -3641,9 +3642,12 @@ class PartialEvaluator {
|
|||
// obtained in step (d), producing a Unicode value.
|
||||
const ucs2 = ucs2CMap.lookup(cid);
|
||||
if (ucs2) {
|
||||
toUnicode[charcode] = String.fromCharCode(
|
||||
(ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1)
|
||||
);
|
||||
buf.length = 0;
|
||||
// Support multi-byte entries (fixes issue16176.pdf).
|
||||
for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
|
||||
buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1));
|
||||
}
|
||||
toUnicode[charcode] = String.fromCharCode(...buf);
|
||||
}
|
||||
});
|
||||
return new ToUnicodeMap(toUnicode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue