function readOpenTypeHeader(ttf) {
return {
- version: ttf.getBytes(4),
+ version: arrayToString(ttf.getBytes(4)),
numTables: int16(ttf.getBytes(2)),
searchRange: int16(ttf.getBytes(2)),
entrySelector: int16(ttf.getBytes(2)),
// The new numbers of tables will be the last one plus the num
// of missing tables
- createOpenTypeHeader('\x00\x01\x00\x00', ttf, numTables);
+ createOpenTypeHeader(header.version, ttf, numTables);
if (requiredTables.indexOf('OS/2') != -1) {
tables.push({
for (var info in data.properties)
properties[info] = data.properties[info];
- var charstrings = this.getOrderedCharStrings(data.charstrings);
+ var charstrings = this.getOrderedCharStrings(data.charstrings, properties);
var type2Charstrings = this.getType2Charstrings(charstrings);
var subrs = this.getType2Subrs(data.subrs);
return null;
},
- getOrderedCharStrings: function cff_getOrderedCharStrings(glyphs) {
+ getOrderedCharStrings: function cff_getOrderedCharStrings(glyphs, properties) {
var charstrings = [];
var missings = [];
for (var i = 0; i < glyphs.length; i++) {
var glyph = glyphs[i];
- var unicode = GlyphsUnicode[glyph.glyph];
- if (!unicode) {
+ var unicode = properties.glyphs[glyph.glyph];
+ if ('undefined' == typeof(unicode)) {
if (glyph.glyph != '.notdef')
missings.push(glyph.glyph);
} else {
var descriptor = xref.fetch(fd);
- var fontName = xref.fetchIfRef(descriptor.get('FontName'));
+ var fontName = fontDict.get('Name');
+ if (!fontName)
+ fontName = xref.fetchIfRef(descriptor.get('FontName'));;
assertWellFormed(IsName(fontName), 'invalid font name');
fontName = fontName.name.replace(/[\+,\-]/g, '_');
glyphWidths[unicode++] = widths[i];
}
+ var glyphsMap = {};
+ for (var p in glyphMap)
+ glyphsMap[glyphMap[p]] = encodingMap[p];
+
var properties = {
type: subType.name,
subtype: fileType,
widths: glyphWidths,
encoding: encodingMap,
+ glyphs: glyphsMap,
builtInEncoding: builtInEncoding,
charset: charset,
firstChar: fontDict.get('FirstChar'),