Browse Source

Basic support for the embedded font file of CIDFontType0

Vivien Nicolas 14 years ago
parent
commit
538d26521d
  1. 23
      fonts.js

23
fonts.js

@ -448,7 +448,7 @@ var Font = (function Font() {
this.mimetype = 'font/opentype'; this.mimetype = 'font/opentype';
var subtype = properties.subtype; var subtype = properties.subtype;
var cff = (subtype === 'Type1C') ? var cff = (subtype == 'Type1C' || properties.type == 'CIDFontType0') ?
new Type2CFF(file, properties) : new CFF(name, file, properties); new Type2CFF(file, properties) : new CFF(name, file, properties);
// Wrap the CFF data inside an OTF font file // Wrap the CFF data inside an OTF font file
@ -2256,11 +2256,16 @@ var Type2CFF = (function() {
var bytes = this.bytes; var bytes = this.bytes;
var privateDict = {};
var privateInfo = topDict.Private; var privateInfo = topDict.Private;
var privOffset = privateInfo[1], privLength = privateInfo[0]; if (privateInfo) {
var privBytes = bytes.subarray(privOffset, privOffset + privLength); var privOffset = privateInfo[1], privLength = privateInfo[0];
baseDict = this.parseDict(privBytes); var privBytes = bytes.subarray(privOffset, privOffset + privLength);
var privDict = this.getPrivDict(baseDict, strings); baseDict = this.parseDict(privBytes);
privateDict = this.getPrivDict(baseDict, strings);
} else {
privateDict.defaultWidthX = properties.defaultWidth;
}
var charStrings = this.parseIndex(topDict.CharStrings); var charStrings = this.parseIndex(topDict.CharStrings);
var charset = this.parseCharsets(topDict.charset, var charset = this.parseCharsets(topDict.charset,
@ -2306,7 +2311,7 @@ var Type2CFF = (function() {
// charstrings contains info about glyphs (one element per glyph // charstrings contains info about glyphs (one element per glyph
// containing mappings for {unicode, width}) // containing mappings for {unicode, width})
var charstrings = this.getCharStrings(charset, charStrings, var charstrings = this.getCharStrings(charset, charStrings,
privDict, this.properties); privateDict, this.properties);
// create the mapping between charstring and glyph id // create the mapping between charstring and glyph id
var glyphIds = []; var glyphIds = [];
@ -2323,10 +2328,8 @@ var Type2CFF = (function() {
}, },
getCharStrings: function cff_charstrings(charsets, charStrings, getCharStrings: function cff_charstrings(charsets, charStrings,
privDict, properties) { privateDict, properties) {
var defaultWidth = privDict['defaultWidthX']; var defaultWidth = privateDict['defaultWidthX'];
var nominalWidth = privDict['nominalWidthX'];
var charstrings = []; var charstrings = [];
var differences = properties.differences; var differences = properties.differences;
var index = 0; var index = 0;

Loading…
Cancel
Save