getLangSysTable method

dynamic getLangSysTable(
  1. dynamic script,
  2. dynamic language,
  3. bool create
)

Returns a language system table @instance @param {string} script='DFLT' @param {string} language='dlft' @param {boolean} create - forces the creation of this langSysTable if it doesn't exist. @return {Object}

Implementation

getLangSysTable(script, language, bool create) {
    var scriptTable = this.getScriptTable(script, create);
    if (scriptTable != null) {
        if (language == null || language == 'dflt' || language == 'DFLT') {
            return scriptTable["defaultLangSys"];
        }
        var pos = searchTag(scriptTable["langSysRecords"], language);
        if (pos >= 0) {
            return scriptTable["langSysRecords"][pos]["langSys"];
        } else if (create) {
            var langSysRecord = {
                "tag": language,
                "langSys": {"reserved": 0, "reqFeatureIndex": 0xffff, "featureIndexes": []}
            };
            scriptTable["langSysRecords"].splice(-1 - pos, 0, langSysRecord);
            return langSysRecord["langSys"];
        }
    }
}