Browse Source

Merge pull request #1720 from yurydelendik/remove-cid-1

Removes the CID data from the CFF font
Brendan Dahl 13 years ago
parent
commit
a9136d9f0f
  1. 19
      src/fonts.js

19
src/fonts.js

@ -3477,7 +3477,7 @@ var CFFFont = (function CFFFontClosure() {
this.properties = properties; this.properties = properties;
var parser = new CFFParser(file, properties); var parser = new CFFParser(file, properties);
var cff = parser.parse(); var cff = parser.parse(true);
var compiler = new CFFCompiler(cff); var compiler = new CFFCompiler(cff);
this.readExtra(cff); this.readExtra(cff);
try { try {
@ -3568,7 +3568,7 @@ var CFFParser = (function CFFParserClosure() {
this.properties = properties; this.properties = properties;
} }
CFFParser.prototype = { CFFParser.prototype = {
parse: function CFFParser_parse() { parse: function CFFParser_parse(normalizeCIDData) {
var properties = this.properties; var properties = this.properties;
var cff = new CFF(); var cff = new CFF();
this.cff = cff; this.cff = cff;
@ -3623,6 +3623,21 @@ var CFFParser = (function CFFParserClosure() {
cff.charset = charset; cff.charset = charset;
cff.encoding = encoding; 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; return cff;
}, },
parseHeader: function CFFParser_parseHeader() { parseHeader: function CFFParser_parseHeader() {

Loading…
Cancel
Save