1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Adjust the heuristics to recognize more cases of unknown glyphs for |toUnicode| (issue 5070)

This commit is contained in:
Jonas Jenwald 2014-07-28 18:41:47 +02:00
parent b918df3547
commit 8ecbb4da05
4 changed files with 22 additions and 0 deletions

View file

@ -4300,6 +4300,7 @@ var Font = (function FontClosure() {
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
@ -4328,12 +4329,25 @@ var Font = (function FontClosure() {
}
break;
case 'C': // Cddd glyph
case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
}
if (code) {
// If |baseEncodingName| is one the predefined encodings,
// and |code| equals |charcode|, using the glyph defined in the
// baseEncoding seems to yield a better |toUnicode| mapping
// (fixes issue 5070).
if (baseEncodingName && code === +charcode) {
var baseEncoding = Encodings[baseEncodingName];
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
toUnicode[charcode] =
String.fromCharCode(GlyphsUnicode[glyphName]);
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
}
continue;