Convert the code in src/core/cff_parser.js
to use ES6 classes
This removes multiple instances of `// eslint-disable-next-line no-shadow`, which our old pseudo-classes necessitated. *Please note:* I'm purposely not doing any `var` to `let`/`const` conversion here, since it's generally better to (if possible) do that automatically on e.g. a directory basis instead.
This commit is contained in:
parent
6bb64da1c3
commit
880a0a0f59
@ -17,6 +17,7 @@ import {
|
||||
bytesToString,
|
||||
FormatError,
|
||||
info,
|
||||
shadow,
|
||||
stringToBytes,
|
||||
Util,
|
||||
warn,
|
||||
@ -218,13 +219,14 @@ var CFFParser = (function CFFParserClosure() {
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFParser(file, properties, seacAnalysisEnabled) {
|
||||
class CFFParser {
|
||||
constructor(file, properties, seacAnalysisEnabled) {
|
||||
this.bytes = file.getBytes();
|
||||
this.properties = properties;
|
||||
this.seacAnalysisEnabled = !!seacAnalysisEnabled;
|
||||
}
|
||||
CFFParser.prototype = {
|
||||
parse: function CFFParser_parse() {
|
||||
|
||||
parse() {
|
||||
var properties = this.properties;
|
||||
var cff = new CFF();
|
||||
this.cff = cff;
|
||||
@ -322,8 +324,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
cff.widths = charStringsAndSeacs.widths;
|
||||
|
||||
return cff;
|
||||
},
|
||||
parseHeader: function CFFParser_parseHeader() {
|
||||
}
|
||||
|
||||
parseHeader() {
|
||||
var bytes = this.bytes;
|
||||
var bytesLength = bytes.length;
|
||||
var offset = 0;
|
||||
@ -347,8 +350,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
var offSize = bytes[3];
|
||||
var header = new CFFHeader(major, minor, hdrSize, offSize);
|
||||
return { obj: header, endPos: hdrSize };
|
||||
},
|
||||
parseDict: function CFFParser_parseDict(dict) {
|
||||
}
|
||||
|
||||
parseDict(dict) {
|
||||
var pos = 0;
|
||||
|
||||
function parseOperand() {
|
||||
@ -420,8 +424,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
},
|
||||
parseIndex: function CFFParser_parseIndex(pos) {
|
||||
}
|
||||
|
||||
parseIndex(pos) {
|
||||
var cffIndex = new CFFIndex();
|
||||
var bytes = this.bytes;
|
||||
var count = (bytes[pos++] << 8) | bytes[pos++];
|
||||
@ -450,24 +455,27 @@ var CFFParser = (function CFFParserClosure() {
|
||||
cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
|
||||
}
|
||||
return { obj: cffIndex, endPos: end };
|
||||
},
|
||||
parseNameIndex: function CFFParser_parseNameIndex(index) {
|
||||
}
|
||||
|
||||
parseNameIndex(index) {
|
||||
var names = [];
|
||||
for (var i = 0, ii = index.count; i < ii; ++i) {
|
||||
var name = index.get(i);
|
||||
names.push(bytesToString(name));
|
||||
}
|
||||
return names;
|
||||
},
|
||||
parseStringIndex: function CFFParser_parseStringIndex(index) {
|
||||
}
|
||||
|
||||
parseStringIndex(index) {
|
||||
var strings = new CFFStrings();
|
||||
for (var i = 0, ii = index.count; i < ii; ++i) {
|
||||
var data = index.get(i);
|
||||
strings.add(bytesToString(data));
|
||||
}
|
||||
return strings;
|
||||
},
|
||||
createDict: function CFFParser_createDict(Type, dict, strings) {
|
||||
}
|
||||
|
||||
createDict(Type, dict, strings) {
|
||||
var cffDict = new Type(strings);
|
||||
for (var i = 0, ii = dict.length; i < ii; ++i) {
|
||||
var pair = dict[i];
|
||||
@ -476,13 +484,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
cffDict.setByKey(key, value);
|
||||
}
|
||||
return cffDict;
|
||||
},
|
||||
parseCharString: function CFFParser_parseCharString(
|
||||
state,
|
||||
data,
|
||||
localSubrIndex,
|
||||
globalSubrIndex
|
||||
) {
|
||||
}
|
||||
|
||||
parseCharString(state, data, localSubrIndex, globalSubrIndex) {
|
||||
if (!data || state.callDepth > MAX_SUBR_NESTING) {
|
||||
return false;
|
||||
}
|
||||
@ -659,7 +663,8 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
state.stackSize = stackSize;
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
parseCharStrings({
|
||||
charStrings,
|
||||
localSubrIndex,
|
||||
@ -728,15 +733,15 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
}
|
||||
return { charStrings, seacs, widths };
|
||||
},
|
||||
emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(
|
||||
parentDict
|
||||
) {
|
||||
}
|
||||
|
||||
emptyPrivateDictionary(parentDict) {
|
||||
var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
|
||||
parentDict.setByKey(18, [0, 0]);
|
||||
parentDict.privateDict = privateDict;
|
||||
},
|
||||
parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
|
||||
}
|
||||
|
||||
parsePrivateDict(parentDict) {
|
||||
// no private dict, do nothing
|
||||
if (!parentDict.hasName("Private")) {
|
||||
this.emptyPrivateDictionary(parentDict);
|
||||
@ -779,8 +784,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
var subrsIndex = this.parseIndex(relativeOffset);
|
||||
privateDict.subrsIndex = subrsIndex.obj;
|
||||
},
|
||||
parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
|
||||
}
|
||||
|
||||
parseCharsets(pos, length, strings, cid) {
|
||||
if (pos === 0) {
|
||||
return new CFFCharset(
|
||||
true,
|
||||
@ -843,13 +849,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
var raw = bytes.subarray(start, end);
|
||||
|
||||
return new CFFCharset(false, format, charset, raw);
|
||||
},
|
||||
parseEncoding: function CFFParser_parseEncoding(
|
||||
pos,
|
||||
properties,
|
||||
strings,
|
||||
charset
|
||||
) {
|
||||
}
|
||||
|
||||
parseEncoding(pos, properties, strings, charset) {
|
||||
var encoding = Object.create(null);
|
||||
var bytes = this.bytes;
|
||||
var predefined = false;
|
||||
@ -916,8 +918,9 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
format = format & 0x7f;
|
||||
return new CFFEncoding(predefined, format, encoding, raw);
|
||||
},
|
||||
parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
|
||||
}
|
||||
|
||||
parseFDSelect(pos, length) {
|
||||
var bytes = this.bytes;
|
||||
var format = bytes[pos++];
|
||||
var fdSelect = [];
|
||||
@ -958,15 +961,14 @@ var CFFParser = (function CFFParserClosure() {
|
||||
}
|
||||
|
||||
return new CFFFDSelect(format, fdSelect);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
return CFFParser;
|
||||
})();
|
||||
|
||||
// Compact Font Format
|
||||
var CFF = (function CFFClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFF() {
|
||||
class CFF {
|
||||
constructor() {
|
||||
this.header = null;
|
||||
this.names = [];
|
||||
this.topDict = null;
|
||||
@ -983,8 +985,8 @@ var CFF = (function CFFClosure() {
|
||||
|
||||
this.isCIDFont = false;
|
||||
}
|
||||
CFF.prototype = {
|
||||
duplicateFirstGlyph: function CFF_duplicateFirstGlyph() {
|
||||
|
||||
duplicateFirstGlyph() {
|
||||
// Browsers will not display a glyph at position 0. Typically glyph 0 is
|
||||
// notdef, but a number of fonts put a valid glyph there so it must be
|
||||
// duplicated and appended.
|
||||
@ -997,37 +999,32 @@ var CFF = (function CFFClosure() {
|
||||
if (this.isCIDFont) {
|
||||
this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
|
||||
}
|
||||
},
|
||||
hasGlyphId: function CFF_hasGlyphID(id) {
|
||||
}
|
||||
|
||||
hasGlyphId(id) {
|
||||
if (id < 0 || id >= this.charStrings.count) {
|
||||
return false;
|
||||
}
|
||||
var glyph = this.charStrings.get(id);
|
||||
return glyph.length > 0;
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return CFF;
|
||||
})();
|
||||
|
||||
var CFFHeader = (function CFFHeaderClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFHeader(major, minor, hdrSize, offSize) {
|
||||
class CFFHeader {
|
||||
constructor(major, minor, hdrSize, offSize) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.hdrSize = hdrSize;
|
||||
this.offSize = offSize;
|
||||
}
|
||||
return CFFHeader;
|
||||
})();
|
||||
}
|
||||
|
||||
var CFFStrings = (function CFFStringsClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFStrings() {
|
||||
class CFFStrings {
|
||||
constructor() {
|
||||
this.strings = [];
|
||||
}
|
||||
CFFStrings.prototype = {
|
||||
get: function CFFStrings_get(index) {
|
||||
|
||||
get(index) {
|
||||
if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
|
||||
return CFFStandardStrings[index];
|
||||
}
|
||||
@ -1035,8 +1032,9 @@ var CFFStrings = (function CFFStringsClosure() {
|
||||
return this.strings[index - NUM_STANDARD_CFF_STRINGS];
|
||||
}
|
||||
return CFFStandardStrings[0];
|
||||
},
|
||||
getSID: function CFFStrings_getSID(str) {
|
||||
}
|
||||
|
||||
getSID(str) {
|
||||
let index = CFFStandardStrings.indexOf(str);
|
||||
if (index !== -1) {
|
||||
return index;
|
||||
@ -1046,45 +1044,44 @@ var CFFStrings = (function CFFStringsClosure() {
|
||||
return index + NUM_STANDARD_CFF_STRINGS;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
add: function CFFStrings_add(value) {
|
||||
}
|
||||
|
||||
add(value) {
|
||||
this.strings.push(value);
|
||||
},
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.strings.length;
|
||||
},
|
||||
};
|
||||
return CFFStrings;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
var CFFIndex = (function CFFIndexClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFIndex() {
|
||||
class CFFIndex {
|
||||
constructor() {
|
||||
this.objects = [];
|
||||
this.length = 0;
|
||||
}
|
||||
CFFIndex.prototype = {
|
||||
add: function CFFIndex_add(data) {
|
||||
|
||||
add(data) {
|
||||
this.length += data.length;
|
||||
this.objects.push(data);
|
||||
},
|
||||
set: function CFFIndex_set(index, data) {
|
||||
}
|
||||
|
||||
set(index, data) {
|
||||
this.length += data.length - this.objects[index].length;
|
||||
this.objects[index] = data;
|
||||
},
|
||||
get: function CFFIndex_get(index) {
|
||||
}
|
||||
|
||||
get(index) {
|
||||
return this.objects[index];
|
||||
},
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.objects.length;
|
||||
},
|
||||
};
|
||||
return CFFIndex;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
var CFFDict = (function CFFDictClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFDict(tables, strings) {
|
||||
class CFFDict {
|
||||
constructor(tables, strings) {
|
||||
this.keyToNameMap = tables.keyToNameMap;
|
||||
this.nameToKeyMap = tables.nameToKeyMap;
|
||||
this.defaults = tables.defaults;
|
||||
@ -1094,9 +1091,9 @@ var CFFDict = (function CFFDictClosure() {
|
||||
this.strings = strings;
|
||||
this.values = Object.create(null);
|
||||
}
|
||||
CFFDict.prototype = {
|
||||
|
||||
// value should always be an array
|
||||
setByKey: function CFFDict_setByKey(key, value) {
|
||||
setByKey(key, value) {
|
||||
if (!(key in this.keyToNameMap)) {
|
||||
return false;
|
||||
}
|
||||
@ -1119,17 +1116,20 @@ var CFFDict = (function CFFDictClosure() {
|
||||
}
|
||||
this.values[key] = value;
|
||||
return true;
|
||||
},
|
||||
setByName: function CFFDict_setByName(name, value) {
|
||||
}
|
||||
|
||||
setByName(name, value) {
|
||||
if (!(name in this.nameToKeyMap)) {
|
||||
throw new FormatError(`Invalid dictionary name "${name}"`);
|
||||
}
|
||||
this.values[this.nameToKeyMap[name]] = value;
|
||||
},
|
||||
hasName: function CFFDict_hasName(name) {
|
||||
}
|
||||
|
||||
hasName(name) {
|
||||
return this.nameToKeyMap[name] in this.values;
|
||||
},
|
||||
getByName: function CFFDict_getByName(name) {
|
||||
}
|
||||
|
||||
getByName(name) {
|
||||
if (!(name in this.nameToKeyMap)) {
|
||||
throw new FormatError(`Invalid dictionary name ${name}"`);
|
||||
}
|
||||
@ -1138,12 +1138,13 @@ var CFFDict = (function CFFDictClosure() {
|
||||
return this.defaults[key];
|
||||
}
|
||||
return this.values[key];
|
||||
},
|
||||
removeByName: function CFFDict_removeByName(name) {
|
||||
}
|
||||
|
||||
removeByName(name) {
|
||||
delete this.values[this.nameToKeyMap[name]];
|
||||
},
|
||||
};
|
||||
CFFDict.createTables = function CFFDict_createTables(layout) {
|
||||
}
|
||||
|
||||
static createTables(layout) {
|
||||
var tables = {
|
||||
keyToNameMap: {},
|
||||
nameToKeyMap: {},
|
||||
@ -1165,9 +1166,8 @@ var CFFDict = (function CFFDictClosure() {
|
||||
tables.order.push(key);
|
||||
}
|
||||
return tables;
|
||||
};
|
||||
return CFFDict;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
var CFFTopDict = (function CFFTopDictClosure() {
|
||||
var layout = [
|
||||
@ -1213,14 +1213,15 @@ var CFFTopDict = (function CFFTopDictClosure() {
|
||||
var tables = null;
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFTopDict(strings) {
|
||||
class CFFTopDict extends CFFDict {
|
||||
constructor(strings) {
|
||||
if (tables === null) {
|
||||
tables = CFFDict.createTables(layout);
|
||||
}
|
||||
CFFDict.call(this, tables, strings);
|
||||
super(tables, strings);
|
||||
this.privateDict = null;
|
||||
}
|
||||
CFFTopDict.prototype = Object.create(CFFDict.prototype);
|
||||
}
|
||||
return CFFTopDict;
|
||||
})();
|
||||
|
||||
@ -1248,14 +1249,15 @@ var CFFPrivateDict = (function CFFPrivateDictClosure() {
|
||||
var tables = null;
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFPrivateDict(strings) {
|
||||
class CFFPrivateDict extends CFFDict {
|
||||
constructor(strings) {
|
||||
if (tables === null) {
|
||||
tables = CFFDict.createTables(layout);
|
||||
}
|
||||
CFFDict.call(this, tables, strings);
|
||||
super(tables, strings);
|
||||
this.subrsIndex = null;
|
||||
}
|
||||
CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
|
||||
}
|
||||
return CFFPrivateDict;
|
||||
})();
|
||||
|
||||
@ -1264,72 +1266,63 @@ var CFFCharsetPredefinedTypes = {
|
||||
EXPERT: 1,
|
||||
EXPERT_SUBSET: 2,
|
||||
};
|
||||
var CFFCharset = (function CFFCharsetClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFCharset(predefined, format, charset, raw) {
|
||||
class CFFCharset {
|
||||
constructor(predefined, format, charset, raw) {
|
||||
this.predefined = predefined;
|
||||
this.format = format;
|
||||
this.charset = charset;
|
||||
this.raw = raw;
|
||||
}
|
||||
return CFFCharset;
|
||||
})();
|
||||
}
|
||||
|
||||
var CFFEncoding = (function CFFEncodingClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFEncoding(predefined, format, encoding, raw) {
|
||||
class CFFEncoding {
|
||||
constructor(predefined, format, encoding, raw) {
|
||||
this.predefined = predefined;
|
||||
this.format = format;
|
||||
this.encoding = encoding;
|
||||
this.raw = raw;
|
||||
}
|
||||
return CFFEncoding;
|
||||
})();
|
||||
}
|
||||
|
||||
var CFFFDSelect = (function CFFFDSelectClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFFDSelect(format, fdSelect) {
|
||||
class CFFFDSelect {
|
||||
constructor(format, fdSelect) {
|
||||
this.format = format;
|
||||
this.fdSelect = fdSelect;
|
||||
}
|
||||
CFFFDSelect.prototype = {
|
||||
getFDIndex: function CFFFDSelect_get(glyphIndex) {
|
||||
|
||||
getFDIndex(glyphIndex) {
|
||||
if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
|
||||
return -1;
|
||||
}
|
||||
return this.fdSelect[glyphIndex];
|
||||
},
|
||||
};
|
||||
return CFFFDSelect;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper class to keep track of where an offset is within the data and helps
|
||||
// filling in that offset once it's known.
|
||||
var CFFOffsetTracker = (function CFFOffsetTrackerClosure() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFOffsetTracker() {
|
||||
class CFFOffsetTracker {
|
||||
constructor() {
|
||||
this.offsets = Object.create(null);
|
||||
}
|
||||
CFFOffsetTracker.prototype = {
|
||||
isTracking: function CFFOffsetTracker_isTracking(key) {
|
||||
|
||||
isTracking(key) {
|
||||
return key in this.offsets;
|
||||
},
|
||||
track: function CFFOffsetTracker_track(key, location) {
|
||||
}
|
||||
|
||||
track(key, location) {
|
||||
if (key in this.offsets) {
|
||||
throw new FormatError(`Already tracking location of ${key}`);
|
||||
}
|
||||
this.offsets[key] = location;
|
||||
},
|
||||
offset: function CFFOffsetTracker_offset(value) {
|
||||
}
|
||||
|
||||
offset(value) {
|
||||
for (var key in this.offsets) {
|
||||
this.offsets[key] += value;
|
||||
}
|
||||
},
|
||||
setEntryLocation: function CFFOffsetTracker_setEntryLocation(
|
||||
key,
|
||||
values,
|
||||
output
|
||||
) {
|
||||
}
|
||||
|
||||
setEntryLocation(key, values, output) {
|
||||
if (!(key in this.offsets)) {
|
||||
throw new FormatError(`Not tracking location of ${key}`);
|
||||
}
|
||||
@ -1359,21 +1352,16 @@ var CFFOffsetTracker = (function CFFOffsetTrackerClosure() {
|
||||
data[offset3] = (value >> 8) & 0xff;
|
||||
data[offset4] = value & 0xff;
|
||||
}
|
||||
},
|
||||
};
|
||||
return CFFOffsetTracker;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
// Takes a CFF and converts it to the binary representation.
|
||||
var CFFCompiler = (function CFFCompilerClosure() {
|
||||
let EncodeFloatRegExp = null; // Lazily initialized by `encodeFloat`.
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
function CFFCompiler(cff) {
|
||||
class CFFCompiler {
|
||||
constructor(cff) {
|
||||
this.cff = cff;
|
||||
}
|
||||
CFFCompiler.prototype = {
|
||||
compile: function CFFCompiler_compile() {
|
||||
|
||||
compile() {
|
||||
var cff = this.cff;
|
||||
var output = {
|
||||
data: [],
|
||||
@ -1483,21 +1471,28 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
output.add([0]);
|
||||
|
||||
return output.data;
|
||||
},
|
||||
encodeNumber: function CFFCompiler_encodeNumber(value) {
|
||||
}
|
||||
|
||||
encodeNumber(value) {
|
||||
if (Number.isInteger(value)) {
|
||||
return this.encodeInteger(value);
|
||||
}
|
||||
return this.encodeFloat(value);
|
||||
},
|
||||
encodeFloat: function CFFCompiler_encodeFloat(num) {
|
||||
}
|
||||
|
||||
static get EncodeFloatRegExp() {
|
||||
return shadow(
|
||||
this,
|
||||
"EncodeFloatRegExp",
|
||||
/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/
|
||||
);
|
||||
}
|
||||
|
||||
encodeFloat(num) {
|
||||
var value = num.toString();
|
||||
|
||||
if (!EncodeFloatRegExp) {
|
||||
EncodeFloatRegExp = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/;
|
||||
}
|
||||
// Rounding inaccurate doubles.
|
||||
var m = EncodeFloatRegExp.exec(value);
|
||||
var m = CFFCompiler.EncodeFloatRegExp.exec(value);
|
||||
if (m) {
|
||||
var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
|
||||
value = (Math.round(num * epsilon) / epsilon).toString();
|
||||
@ -1523,8 +1518,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
out.push(parseInt(nibbles.substring(i, i + 2), 16));
|
||||
}
|
||||
return out;
|
||||
},
|
||||
encodeInteger: function CFFCompiler_encodeInteger(value) {
|
||||
}
|
||||
|
||||
encodeInteger(value) {
|
||||
var code;
|
||||
if (value >= -107 && value <= 107) {
|
||||
code = [value + 139];
|
||||
@ -1546,11 +1542,13 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
];
|
||||
}
|
||||
return code;
|
||||
},
|
||||
compileHeader: function CFFCompiler_compileHeader(header) {
|
||||
}
|
||||
|
||||
compileHeader(header) {
|
||||
return [header.major, header.minor, header.hdrSize, header.offSize];
|
||||
},
|
||||
compileNameIndex: function CFFCompiler_compileNameIndex(names) {
|
||||
}
|
||||
|
||||
compileNameIndex(names) {
|
||||
var nameIndex = new CFFIndex();
|
||||
for (var i = 0, ii = names.length; i < ii; ++i) {
|
||||
var name = names[i];
|
||||
@ -1587,12 +1585,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
nameIndex.add(stringToBytes(sanitizedName));
|
||||
}
|
||||
return this.compileIndex(nameIndex);
|
||||
},
|
||||
compileTopDicts: function CFFCompiler_compileTopDicts(
|
||||
dicts,
|
||||
length,
|
||||
removeCidKeys
|
||||
) {
|
||||
}
|
||||
|
||||
compileTopDicts(dicts, length, removeCidKeys) {
|
||||
var fontDictTrackers = [];
|
||||
var fdArrayIndex = new CFFIndex();
|
||||
for (var i = 0, ii = dicts.length; i < ii; ++i) {
|
||||
@ -1615,12 +1610,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
trackers: fontDictTrackers,
|
||||
output: fdArrayIndex,
|
||||
};
|
||||
},
|
||||
compilePrivateDicts: function CFFCompiler_compilePrivateDicts(
|
||||
dicts,
|
||||
trackers,
|
||||
output
|
||||
) {
|
||||
}
|
||||
|
||||
compilePrivateDicts(dicts, trackers, output) {
|
||||
for (var i = 0, ii = dicts.length; i < ii; ++i) {
|
||||
var fontDict = dicts[i];
|
||||
var privateDict = fontDict.privateDict;
|
||||
@ -1656,8 +1648,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
output.add(subrs);
|
||||
}
|
||||
}
|
||||
},
|
||||
compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
|
||||
}
|
||||
|
||||
compileDict(dict, offsetTracker) {
|
||||
var out = [];
|
||||
// The dictionary keys must be in a certain order.
|
||||
var order = dict.order;
|
||||
@ -1714,19 +1707,22 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
out = out.concat(dict.opcodes[key]);
|
||||
}
|
||||
return out;
|
||||
},
|
||||
compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
|
||||
}
|
||||
|
||||
compileStringIndex(strings) {
|
||||
var stringIndex = new CFFIndex();
|
||||
for (var i = 0, ii = strings.length; i < ii; ++i) {
|
||||
stringIndex.add(stringToBytes(strings[i]));
|
||||
}
|
||||
return this.compileIndex(stringIndex);
|
||||
},
|
||||
compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
|
||||
}
|
||||
|
||||
compileGlobalSubrIndex() {
|
||||
var globalSubrIndex = this.cff.globalSubrIndex;
|
||||
this.out.writeByteArray(this.compileIndex(globalSubrIndex));
|
||||
},
|
||||
compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
|
||||
}
|
||||
|
||||
compileCharStrings(charStrings) {
|
||||
var charStringsIndex = new CFFIndex();
|
||||
for (var i = 0; i < charStrings.count; i++) {
|
||||
var glyph = charStrings.get(i);
|
||||
@ -1739,13 +1735,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
charStringsIndex.add(glyph);
|
||||
}
|
||||
return this.compileIndex(charStringsIndex);
|
||||
},
|
||||
compileCharset: function CFFCompiler_compileCharset(
|
||||
charset,
|
||||
numGlyphs,
|
||||
strings,
|
||||
isCIDFont
|
||||
) {
|
||||
}
|
||||
|
||||
compileCharset(charset, numGlyphs, strings, isCIDFont) {
|
||||
// Freetype requires the number of charset strings be correct and MacOS
|
||||
// requires a valid mapping for printing.
|
||||
let out;
|
||||
@ -1785,11 +1777,13 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
}
|
||||
}
|
||||
return this.compileTypedArray(out);
|
||||
},
|
||||
compileEncoding: function CFFCompiler_compileEncoding(encoding) {
|
||||
}
|
||||
|
||||
compileEncoding(encoding) {
|
||||
return this.compileTypedArray(encoding.raw);
|
||||
},
|
||||
compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
|
||||
}
|
||||
|
||||
compileFDSelect(fdSelect) {
|
||||
const format = fdSelect.format;
|
||||
let out, i;
|
||||
switch (format) {
|
||||
@ -1828,16 +1822,17 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
break;
|
||||
}
|
||||
return this.compileTypedArray(out);
|
||||
},
|
||||
compileTypedArray: function CFFCompiler_compileTypedArray(data) {
|
||||
}
|
||||
|
||||
compileTypedArray(data) {
|
||||
var out = [];
|
||||
for (var i = 0, ii = data.length; i < ii; ++i) {
|
||||
out[i] = data[i];
|
||||
}
|
||||
return out;
|
||||
},
|
||||
compileIndex: function CFFCompiler_compileIndex(index, trackers) {
|
||||
trackers = trackers || [];
|
||||
}
|
||||
|
||||
compileIndex(index, trackers = []) {
|
||||
var objects = index.objects;
|
||||
// First 2 bytes contains the number of objects contained into this index
|
||||
var count = objects.length;
|
||||
@ -1907,10 +1902,8 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return CFFCompiler;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
CFFStandardStrings,
|
||||
|
Loading…
Reference in New Issue
Block a user