Skip to content

Commit

Permalink
Proper glyph selection for CIDFontType0C fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandahl committed Oct 1, 2013
1 parent ea50c07 commit f79c182
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/core/fonts.js
Expand Up @@ -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) {
Expand Down
Binary file added test/pdfs/bug921409.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Expand Up @@ -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",
Expand Down

0 comments on commit f79c182

Please sign in to comment.