parseValueRecord method

Map<String, dynamic>? parseValueRecord(
  1. dynamic valueFormat
)

Parse a GPOS valueRecord https://docs.microsoft.com/en-us/typography/opentype/spec/gpos#value-record valueFormat is optional, if omitted it is read from the stream.

Implementation

Map<String, dynamic>? parseValueRecord(valueFormat) {
    if (valueFormat == null) {
        valueFormat = parseUShort();
    }
    if (valueFormat == 0) {
        // valueFormat2 in kerning pairs is most often 0
        // in this case return null instead of an empty object, to save space
        return null;
    }

    Map<String, dynamic> valueRecord = {};

    if ((valueFormat & 0x0001) != 0) { valueRecord["xPlacement"] = this.parseShort(); }
    if ((valueFormat & 0x0002) != 0) { valueRecord["yPlacement"] = this.parseShort(); }
    if ((valueFormat & 0x0004) != 0) { valueRecord["xAdvance"] = this.parseShort(); }
    if ((valueFormat & 0x0008) != 0) { valueRecord["yAdvance"] = this.parseShort(); }

    // Device table (non-variable font) / VariationIndex table (variable font) not supported
    // https://docs.microsoft.com/fr-fr/typography/opentype/spec/chapter2#devVarIdxTbls
    if ((valueFormat & 0x0010) != 0) { valueRecord["xPlaDevice"] = null; this.parseShort(); }
    if ((valueFormat & 0x0020) != 0) { valueRecord["yPlaDevice"] = null; this.parseShort(); }
    if ((valueFormat & 0x0040) != 0) { valueRecord["xAdvDevice"] = null; this.parseShort(); }
    if ((valueFormat & 0x0080) != 0) { valueRecord["yAdvDevice"] = null; this.parseShort(); }

    return valueRecord;
}