Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)
This patch slightly extends the heuristics used when trying to skip mapping of missing glyphs. Fixes 5677.
This commit is contained in:
parent
99415a75b7
commit
aa3a64e975
@ -4130,13 +4130,17 @@ var Font = (function FontClosure() {
|
||||
|
||||
var charCodeToGlyphId = [], charCode;
|
||||
var toUnicode = properties.toUnicode, widths = properties.widths;
|
||||
var isIdentityUnicode = toUnicode instanceof IdentityToUnicodeMap;
|
||||
var skipToUnicode = (toUnicode instanceof IdentityToUnicodeMap ||
|
||||
toUnicode.length === 0x10000);
|
||||
|
||||
// Helper function to try to skip mapping of empty glyphs.
|
||||
// Note: In some cases, just relying on the glyph data doesn't work,
|
||||
// hence we also use a few heuristics to fix various PDF files.
|
||||
function hasGlyph(glyphId, charCode, widthCode) {
|
||||
if (!missingGlyphs[glyphId]) {
|
||||
return true;
|
||||
}
|
||||
if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) {
|
||||
if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
|
||||
return true;
|
||||
}
|
||||
if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -25,6 +25,7 @@
|
||||
!issue4630.pdf
|
||||
!issue5202.pdf
|
||||
!issue5280.pdf
|
||||
!issue5677.pdf
|
||||
!issue5954.pdf
|
||||
!alphatrans.pdf
|
||||
!devicen.pdf
|
||||
|
BIN
test/pdfs/issue5677.pdf
Normal file
BIN
test/pdfs/issue5677.pdf
Normal file
Binary file not shown.
@ -558,6 +558,13 @@
|
||||
"link": false,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "issue5677",
|
||||
"file": "pdfs/issue5677.pdf",
|
||||
"md5": "c9101578fcb806269145132724d24ac1",
|
||||
"rounds": 1,
|
||||
"link": false,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue5954",
|
||||
"file": "pdfs/issue5954.pdf",
|
||||
"md5": "4f60ec0d9bbeec845b681242b8982361",
|
||||
|
Loading…
Reference in New Issue
Block a user