Implement GSUB subtables
Pomax opened this issue · comments
Pomax commented
const font = e.detail.font;
const { name, GSUB } = font.opentype.tables;
const liga = GSUB.getFeature(`liga`);
const lookupIDs = liga.lookupListIndices;
lookupIDs.forEach(id => {
const lookup = GSUB.getLookup(id);
const subtables = lookup.getSubTables();
console.log(lookup, subtables);
});
yields:
LookupTable {
lookupType: 4,
lookupFlag: 0,
subTableCount: 1,
subtableOffsets: [ 8 ],
markFilteringSet: 1
} [
CoverageTable {
coverageFormat: 1,
glyphCount: 4056,
glyphArray: [
1, 8, 4, 10, 18, 26, 32, 734, 3, 300, 946, 735,
3, 300, 964, 732, 2, 946, 733, 2, 964, 1, 0, 1,
8, 1, 6, 929, 2, 1, 240, 264, 0, 1, 0, 1,
8, 2, 22, 8, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1195,
2, 2, 301, 307, 0, 1062, 1062, 7, 1, 0, 1, 8,
2, 10, 2, 1194, 1194, 1, 2, 300, 1061, 2, 0, 1,
8, 1, 64, 29, 92, 96, 100, 104, 108, 112, 116, 120,
124, 128, 132, 136, 140, 144, 86, 92, 96, 100, 104, 108,
112, 116, 120, 124,
... 3956 more items
]
}
]
which makes no sense. This should obvioulsy be a GSUB lookup type 4 subtable, but the subtable code currently reads:
getSubTables() {
return this.subtableOffsets.map((offset) => {
this.parser.currentPosition = this.start + offset;
return new CoverageTable(this.parser);
});
}
Which is rather wrong: the lookup table does not reference coverage tables, the lookup table has a list of subtable(s) (which type of subtable depending on the lookup type), and those will refer to a coverage table.