parseLocaTable function

dynamic parseLocaTable(
  1. dynamic data,
  2. dynamic start,
  3. dynamic numGlyphs,
  4. dynamic shortVersion,
)

Implementation

parseLocaTable(data, start, numGlyphs, shortVersion) {
    var p = new Parser(data, start);
    var parseFn = shortVersion ? parseUShort2 : parseULong2;
    // There is an extra entry after the last index element to compute the length of the last glyph.
    // That's why we use numGlyphs + 1.
    var glyphOffsets = [];
    for (var i = 0; i < numGlyphs + 1; i += 1) {
        var glyphOffset = parseFn(p);
        if (shortVersion) {
            // The short table version stores the actual offset divided by 2.
            glyphOffset *= 2;
        }

        glyphOffsets.add(glyphOffset);
    }

    return glyphOffsets;
}