addSingle top-level property
Null Function(dynamic feature, dynamic substitution, dynamic script, dynamic language)
addSingle
getter/setter pair
Implementation
Substitution.prototype.addSingle = function(feature, substitution, script, language) {
const lookupTable = this.getLookupTables(script, language, feature, 1, true)[0];
const subtable = getSubstFormat(lookupTable, 2, { // lookup type 1 subtable, format 2, coverage format 1
substFormat: 2,
coverage: {format: 1, glyphs: []},
substitute: []
});
check.assert(subtable.coverage.format === 1, 'Single: unable to modify coverage table format ' + subtable.coverage.format);
const coverageGlyph = substitution.sub;
let pos = this.binSearch(subtable.coverage.glyphs, coverageGlyph);
if (pos < 0) {
pos = -1 - pos;
subtable.coverage.glyphs.splice(pos, 0, coverageGlyph);
subtable.substitute.splice(pos, 0, 0);
}
subtable.substitute[pos] = substitution.by;
};