parseLookup2 function

dynamic parseLookup2(
  1. dynamic scope
)

Implementation

parseLookup2(scope) {
    var start = scope.offset + scope.relativeOffset;
    var posFormat = scope.parseUShort();
    assertfn(posFormat == 1 || posFormat == 2, '0x' + start.toString() + ': GPOS lookup type 2 format must be 1 or 2.');
    var coverage = scope.parsePointer(Parser.coverage);
    var valueFormat1 = scope.parseUShort();
    var valueFormat2 = scope.parseUShort();
    if (posFormat == 1) {
        // Adjustments for Glyph Pairs
        return {
            "posFormat": posFormat,
            "coverage": coverage,
            "valueFormat1": valueFormat1,
            "valueFormat2": valueFormat2,
            "pairSets": scope.parseList(
              Parser.pointer(
                Parser.list(
                  (scope) {
                    return {        // pairValueRecord
                      "secondGlyph": scope.parseUShort(),
                      "value1": scope.parseValueRecord(valueFormat1),
                      "value2": scope.parseValueRecord(valueFormat2)
                    };
                  },
                  null
                )
              ),
              null
            )
        };
    } else if (posFormat == 2) {
        var classDef1 = scope.parsePointer(Parser.classDef);
        var classDef2 = scope.parsePointer(Parser.classDef);
        var class1Count = scope.parseUShort();
        var class2Count = scope.parseUShort();
        return {
            // Class Pair Adjustment
            "posFormat": posFormat,
            "coverage": coverage,
            "valueFormat1": valueFormat1,
            "valueFormat2": valueFormat2,
            "classDef1": classDef1,
            "classDef2": classDef2,
            "class1Count": class1Count,
            "class2Count": class2Count,
            "classRecords": scope.parseList(class1Count, Parser.list(class2Count, () {
                return {
                    "value1": scope.parseValueRecord(valueFormat1),
                    "value2": scope.parseValueRecord(valueFormat2)
                };
            }))
        };
    }
}