Skip to content

Commit

Permalink
Merge pull request #13985 from Snuffleupagus/issue-11088
Browse files Browse the repository at this point in the history
Improve glyph mapping for non-embedded composite standard fonts (issue 11088)
  • Loading branch information
timvandermeij authored Sep 8, 2021
2 parents 168aa5e + 69034ab commit 8a79f13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -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 = [];
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue11088.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/3533108/default.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4003,6 +4003,14 @@
"link": false,
"type": "eq"
},
{ "id": "issue11088",
"file": "pdfs/issue11088.pdf",
"md5": "c46e7d81197fae61a52e00efb30dd7ce",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue11287",
"file": "pdfs/issue11287.pdf",
"md5": "d7d6a7c124fad7b00f79112b71ee09d6",
Expand Down

0 comments on commit 8a79f13

Please sign in to comment.