diff --git a/src/core/fonts.js b/src/core/fonts.js index 154c3f087..f4f8ef9a4 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -5529,18 +5529,22 @@ var CFFFont = (function CFFFontClosure() { var unassignedUnicodeItems = []; var inverseEncoding = []; var gidStart = 0; - // Even though the CFF font may not actually be a CID font is could have - // CID information in the font descriptor. - if (this.properties.cidSystemInfo) { - // According to section 9.7.4.2 if the font is actually a CID font then - // we should use the charset to map CIDs to GIDs. If it is not actually - // a CID font then CIDs can be mapped directly to GIDs. + // According to section 9.7.4.2 CIDFontType0C glyph selection should be + // handled differently. + if (this.properties.subtype === 'CIDFontType0C') { if (this.cff.isCIDFont) { + // If the font is actually a CID font then we should use the charset + // to map CIDs to GIDs. inverseEncoding = charsets; } else { - for (var i = 0, ii = charsets.length; i < charsets.length; i++) { + // If it is NOT actually a CID font then CIDs should be mapped + // directly to GIDs. + inverseEncoding = []; + for (var i = 0, ii = cff.charStrings.count; i < ii; i++) { inverseEncoding.push(i); } + // Use the identity map for charsets as well. + charsets = inverseEncoding; } } else { for (var charcode in encoding) { diff --git a/test/pdfs/bug921409.pdf b/test/pdfs/bug921409.pdf new file mode 100644 index 000000000..1e1330031 Binary files /dev/null and b/test/pdfs/bug921409.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 6b245d729..2ef31bf61 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1162,6 +1162,13 @@ "type": "eq", "about": "A CIDFontType0 font with a CFF font that isn't actually CID." }, + { "id": "bug921409", + "file": "pdfs/bug921409.pdf", + "md5": "920e88dde0f5436ebe0df0281e1c30ca", + "rounds": 1, + "type": "eq", + "about": "A CIDFontType0 font that actually has a Type1C font file." + }, { "id": "noembed-identity-2", "file": "pdfs/noembed-identity-2.pdf", "md5": "13b7d9ab9579d45c10bc8d499d087f21",