parseCFFEncoding function
dynamic
parseCFFEncoding(
- dynamic data,
- dynamic start,
- dynamic charset
Implementation
parseCFFEncoding(data, start, charset) {
var code;
var enc = {};
var parser = new Parser(data, start);
var format = parser.parseCard8();
if (format == 0) {
var nCodes = parser.parseCard8();
for (var i = 0; i < nCodes; i += 1) {
code = parser.parseCard8();
enc[code] = i;
}
} else if (format == 1) {
var nRanges = parser.parseCard8();
code = 1;
for (var i = 0; i < nRanges; i += 1) {
var first = parser.parseCard8();
var nLeft = parser.parseCard8();
for (var j = first; j <= first + nLeft; j += 1) {
enc[j] = code;
code += 1;
}
}
} else {
throw ('Unknown encoding format ' + format);
}
return new CffEncoding(enc, charset);
}