Create the glyph mapping correctly for composite Type1, i.e. CIDFontType0, fonts (issue 11740)

This updates `Type1Font.getGlyphMapping` with a code-path "borrowed" from `CFFFont.getGlyphMapping`.
This commit is contained in:
Jonas Jenwald 2020-03-25 14:06:01 +01:00
parent 6a8c591301
commit 938d519192
4 changed files with 23 additions and 0 deletions

View File

@ -3635,6 +3635,22 @@ var Type1Font = (function Type1FontClosure() {
getGlyphMapping: function Type1Font_getGlyphMapping(properties) { getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
var charstrings = this.charstrings; var charstrings = this.charstrings;
if (properties.composite) {
const charCodeToGlyphId = Object.create(null);
// Map CIDs directly to GIDs.
for (
let glyphId = 0, charstringsLen = charstrings.length;
glyphId < charstringsLen;
glyphId++
) {
const charCode = properties.cMap.charCodeOf(glyphId);
// Add 1 because glyph 0 is duplicated.
charCodeToGlyphId[charCode] = glyphId + 1;
}
return charCodeToGlyphId;
}
var glyphNames = [".notdef"], var glyphNames = [".notdef"],
glyphId; glyphId;
for (glyphId = 0; glyphId < charstrings.length; glyphId++) { for (glyphId = 0; glyphId < charstrings.length; glyphId++) {

View File

@ -206,6 +206,7 @@
!bug1011159.pdf !bug1011159.pdf
!issue5734.pdf !issue5734.pdf
!issue4875.pdf !issue4875.pdf
!issue11740_reduced.pdf
!issue4881.pdf !issue4881.pdf
!issue5994.pdf !issue5994.pdf
!issue6151.pdf !issue6151.pdf

Binary file not shown.

View File

@ -904,6 +904,12 @@
"link": false, "link": false,
"type": "eq" "type": "eq"
}, },
{ "id": "issue11740",
"file": "pdfs/issue11740_reduced.pdf",
"md5": "f3f2957f171af52229c6e749e8a5572b",
"rounds": 1,
"type": "eq"
},
{ "id": "issue10491", { "id": "issue10491",
"file": "pdfs/issue10491.pdf", "file": "pdfs/issue10491.pdf",
"md5": "0759ec46739b13bb0b66170a18d33d4f", "md5": "0759ec46739b13bb0b66170a18d33d4f",