Merge pull request #13970 from Snuffleupagus/issue-13316

Fallback to the /ToUnicode map for TrueType fonts with (3, 1) and (1, 0) cmap-tables (issue 13316)
This commit is contained in:
Jonas Jenwald 2021-09-04 09:34:39 +02:00 committed by GitHub
commit 258cf1decc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 0 deletions

View File

@ -2651,6 +2651,25 @@ class Font {
unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
}
if (unicodeOrCharCode === undefined) {
// Not a valid glyph name, fallback to using the /ToUnicode map
// when no post-table exists (fixes issue13316_reduced.pdf).
if (
!properties.glyphNames &&
properties.hasIncludedToUnicodeMap &&
!(this.toUnicode instanceof IdentityToUnicodeMap)
) {
const unicode = this.toUnicode.get(charCode);
if (unicode) {
unicodeOrCharCode = unicode.codePointAt(0);
}
}
if (unicodeOrCharCode === undefined) {
continue; // No valid glyph mapping found.
}
}
for (let i = 0; i < cmapMappingsLength; ++i) {
if (cmapMappings[i].charCode !== unicodeOrCharCode) {
continue;

View File

@ -240,6 +240,7 @@
!issue4304.pdf
!issue4379.pdf
!issue4550.pdf
!issue13316_reduced.pdf
!issue4575.pdf
!bug1011159.pdf
!issue5734.pdf

Binary file not shown.

View File

@ -4321,6 +4321,12 @@
"lastPage": 4,
"type": "load"
},
{ "id": "issue13316",
"file": "pdfs/issue13316_reduced.pdf",
"md5": "f5821891cee29d8de8b65e1efd6f4ceb",
"rounds": 1,
"type": "eq"
},
{ "id": "issue10519",
"file": "pdfs/issue10519_reduced.pdf",
"md5": "8a2dae43c0ef47b0734bedaaa24f8c09",