Skip to content

Commit

Permalink
Removes the CID data from the CFF font
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed May 18, 2012
1 parent b2a3092 commit ed02be8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3477,7 +3477,7 @@ var CFFFont = (function CFFFontClosure() {
this.properties = properties;

var parser = new CFFParser(file, properties);
var cff = parser.parse();
var cff = parser.parse(true);
var compiler = new CFFCompiler(cff);
this.readExtra(cff);
try {
Expand Down Expand Up @@ -3568,7 +3568,7 @@ var CFFParser = (function CFFParserClosure() {
this.properties = properties;
}
CFFParser.prototype = {
parse: function CFFParser_parse() {
parse: function CFFParser_parse(normalizeCIDData) {
var properties = this.properties;
var cff = new CFF();
this.cff = cff;
Expand Down Expand Up @@ -3623,6 +3623,21 @@ var CFFParser = (function CFFParserClosure() {
cff.charset = charset;
cff.encoding = encoding;

if (!cff.isCIDFont || !normalizeCIDData)
return cff;

// DirectWrite does not like CID fonts data. Trying to convert/flatten
// the font data and remove CID properties.
if (cff.fdArray.length !== 1)
error('Unable to normalize CID font in CFF data');

var fontDict = cff.fdArray[0];
fontDict.setByKey(17, topDict.getByName('CharStrings'));
cff.topDict = fontDict;
cff.isCIDFont = false;
delete cff.fdArray;
delete cff.fdSelect;

return cff;
},
parseHeader: function CFFParser_parseHeader() {
Expand Down

0 comments on commit ed02be8

Please sign in to comment.