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

Improve glyph mapping for non-embedded composite standard fonts (issue 11088)

For non-embedded CIDFontType2 fonts with a non-/Identity encoding, use the /ToUnicode data to improve the glyph mapping.
This commit is contained in:
Jonas Jenwald 2021-09-08 14:46:39 +02:00
parent d95f680d66
commit 69034ab8dc
3 changed files with 22 additions and 3 deletions

View file

@ -1084,8 +1084,7 @@ class Font {
}
}
const isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
if (!isIdentityUnicode) {
if (!(this.toUnicode instanceof IdentityToUnicodeMap)) {
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
map[+charCode] = unicodeCharCode;
});
@ -1108,11 +1107,22 @@ class Font {
this.differences
);
} else if (isStandardFont) {
this.toFontChar = buildToFontChar(
const map = buildToFontChar(
this.defaultEncoding,
getGlyphsUnicode(),
this.differences
);
if (
type === "CIDFontType2" &&
!this.cidEncoding.startsWith("Identity-") &&
!(this.toUnicode instanceof IdentityToUnicodeMap)
) {
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
map[+charCode] = unicodeCharCode;
});
}
this.toFontChar = map;
} else {
const glyphsUnicodeMap = getGlyphsUnicode();
const map = [];