getFeatureTable method
Get a specific feature table.
@instance
@param {string} script='DFLT'
@param {string} language='dlft'
@param {string} feature - One of the codes listed at https://www.microsoft.com/typography/OTSPEC/featurelist.htm
@param {boolean} create - forces the creation of the feature table if it doesn't exist.
@return {Object}
Implementation
getFeatureTable(script, language, feature, bool create) {
var langSysTable = this.getLangSysTable(script, language, create);
if (langSysTable != null) {
var featureRecord;
var featIndexes = langSysTable["featureIndexes"];
var allFeatures = this.font.tables[this.tableName]["features"];
// The FeatureIndex array of indices is in arbitrary order,
// even if allFeatures is sorted alphabetically by feature tag.
for (var i = 0; i < featIndexes.length; i++) {
featureRecord = allFeatures[featIndexes[i]];
if (featureRecord["tag"] == feature) {
return featureRecord["feature"];
}
}
if (create) {
var index = allFeatures.length;
// Automatic ordering of features would require to shift feature indexes in the script list.
assertfn(index == 0 || feature >= allFeatures[index - 1]["tag"], 'Features must be added in alphabetical order.');
featureRecord = {
"tag": feature,
"feature": { "params": 0, "lookupListIndexes": [] }
};
allFeatures.add(featureRecord);
featIndexes.add(index);
return featureRecord["feature"];
}
}
}