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:
parent
d95f680d66
commit
69034ab8dc
@ -1084,8 +1084,7 @@ class Font {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
|
if (!(this.toUnicode instanceof IdentityToUnicodeMap)) {
|
||||||
if (!isIdentityUnicode) {
|
|
||||||
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
|
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
|
||||||
map[+charCode] = unicodeCharCode;
|
map[+charCode] = unicodeCharCode;
|
||||||
});
|
});
|
||||||
@ -1108,11 +1107,22 @@ class Font {
|
|||||||
this.differences
|
this.differences
|
||||||
);
|
);
|
||||||
} else if (isStandardFont) {
|
} else if (isStandardFont) {
|
||||||
this.toFontChar = buildToFontChar(
|
const map = buildToFontChar(
|
||||||
this.defaultEncoding,
|
this.defaultEncoding,
|
||||||
getGlyphsUnicode(),
|
getGlyphsUnicode(),
|
||||||
this.differences
|
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 {
|
} else {
|
||||||
const glyphsUnicodeMap = getGlyphsUnicode();
|
const glyphsUnicodeMap = getGlyphsUnicode();
|
||||||
const map = [];
|
const map = [];
|
||||||
|
1
test/pdfs/issue11088.pdf.link
Normal file
1
test/pdfs/issue11088.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/3533108/default.pdf
|
@ -4003,6 +4003,14 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue11088",
|
||||||
|
"file": "pdfs/issue11088.pdf",
|
||||||
|
"md5": "c46e7d81197fae61a52e00efb30dd7ce",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue11287",
|
{ "id": "issue11287",
|
||||||
"file": "pdfs/issue11287.pdf",
|
"file": "pdfs/issue11287.pdf",
|
||||||
"md5": "d7d6a7c124fad7b00f79112b71ee09d6",
|
"md5": "d7d6a7c124fad7b00f79112b71ee09d6",
|
||||||
|
Loading…
Reference in New Issue
Block a user