Proper glyph selection for CIDFontType0C fonts.

This commit is contained in:
Brendan Dahl 2013-09-30 21:40:28 -07:00
parent ea50c078b0
commit f79c182314
3 changed files with 18 additions and 7 deletions

View File

@ -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) {

BIN
test/pdfs/bug921409.pdf Normal file

Binary file not shown.

View File

@ -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",