parseFvarTable function

dynamic parseFvarTable(
  1. dynamic data,
  2. dynamic start,
  3. dynamic names
)

Implementation

parseFvarTable(data, start, names) {
    var p = new Parser(data, start);
    var tableVersion = p.parseULong();
    argument(tableVersion == 0x00010000, 'Unsupported fvar table version.');
    var offsetToData = p.parseOffset16();
    // Skip countSizePairs.
    p.skip('uShort', 1);
    var axisCount = p.parseUShort();
    var axisSize = p.parseUShort();
    var instanceCount = p.parseUShort();
    var instanceSize = p.parseUShort();

    var axes = [];
    for (var i = 0; i < axisCount; i++) {
        axes.add(parseFvarAxis(data, start + offsetToData + i * axisSize, names));
    }

    var instances = [];
    var instanceStart = start + offsetToData + axisCount * axisSize;
    for (var j = 0; j < instanceCount; j++) {
        instances.add(parseFvarInstance(data, instanceStart + j * instanceSize, axes, names));
    }

    return {"axes": axes, "instances": instances};
}