getSubstFormat function

dynamic getSubstFormat(
  1. dynamic lookupTable,
  2. dynamic format,
  3. dynamic defaultSubtable
)

Implementation

function getSubstFormat(lookupTable, format, defaultSubtable) {
    const subtables = lookupTable.subtables;
    for (let i = 0; i < subtables.length; i++) {
        const subtable = subtables[i];
        if (subtable.substFormat === format) {
            return subtable;
        }
    }
    if (defaultSubtable) {
        subtables.push(defaultSubtable);
        return defaultSubtable;
    }
    return undefined;
}