getScriptTable method

dynamic getScriptTable(
  1. dynamic script,
  2. dynamic create
)

Returns all LangSysRecords in the given script. @instance @param {string} script='DFLT' @param {boolean} create - forces the creation of this script table if it doesn't exist. @return {Object} An object with tag and script properties.

Implementation

getScriptTable(script, create) {
  var layout = this.getTable(create);
  if (layout != null) {
    script = script ?? 'DFLT';
    var scripts = layout["scripts"];
    var pos = searchTag(layout["scripts"], script);
    if (pos >= 0) {
        return scripts[pos]["script"];
    } else if (create) {
        var scr = {
            "tag": script,
            "script": {
                "defaultLangSys": {"reserved": 0, "reqFeatureIndex": 0xffff, "featureIndexes": []},
                "langSysRecords": []
            }
        };
        scripts.splice(-1 - pos, 0, scr);
        return scr["script"];
    }
  }
}