parse static method
Implementation
static Map<String, dynamic> parse(Uint8List buffer, int offset, int length) {
Uint8List data = buffer.sublist(offset, offset + length);
offset = 0;
Map<String, dynamic> obj = {};
offset += 2;
int numTables = TyprBin.readUshort(data, offset);
offset += 2;
//console.warn(version, numTables);
final List<int> offs = [];
obj["tables"] = [];
for (int i = 0; i < numTables; i++) {
int platformID = TyprBin.readUshort(data, offset);
offset += 2;
int encodingID = TyprBin.readUshort(data, offset);
offset += 2;
int noffset = TyprBin.readUint(data, offset);
offset += 4;
String id = "p${platformID}e${encodingID}";
//console.warn("cmap subtable", platformID, encodingID, noffset);
int tind = offs.indexOf(noffset);
if (tind == -1) {
tind = obj["tables"].length;
Map<String, dynamic>? subt;
offs.add(noffset);
int format = TyprBin.readUshort(data, noffset);
if (format == 0)
subt = parse0(data, noffset);
else if (format == 4)
subt = parse4(data, noffset);
else if (format == 6)
subt = parse6(data, noffset);
else if (format == 12)
subt = parse12(data, noffset);
else
console.warning("unknown format: ${format} platformID: ${platformID} encodingID: ${encodingID} noffset: ${noffset}");
obj["tables"].add(subt);
}
if (obj[id] != null) throw "multiple tables for one platform+encoding";
obj[id] = tind;
}
return obj;
}