Beispiel #1
0
        public static Format0SubTable Load(BinaryReader reader, KerningCoverage coverage)
        {
            // Type   | Field         | Description
            // -------|---------------|--------------------------------------------------------
            // uint16 | nPairs        | This gives the number of kerning pairs in the table.
            // uint16 | searchRange   | The largest power of two less than or equal to the value of nPairs, multiplied by the size in bytes of an entry in the table.
            // uint16 | entrySelector | This is calculated as log2 of the largest power of two less than or equal to the value of nPairs.This value indicates how many iterations of the search loop will have to be made. (For example, in a list of eight items, there would have to be three iterations of the loop).
            // uint16 | rangeShift    | The value of nPairs minus the largest power of two less than or equal to nPairs, and then multiplied by the size in bytes of an entry in the table.
            ushort pairCount     = reader.ReadUInt16();
            ushort searchRange   = reader.ReadUInt16();
            ushort entrySelector = reader.ReadUInt16();
            ushort rangeShift    = reader.ReadUInt16();

            Kern.KearningPair[] pairs = new KearningPair[pairCount];
            for (int i = 0; i < pairCount; i++)
            {
                pairs[i] = KearningPair.Read(reader);
            }

            return(new Format0SubTable(pairs, coverage));
        }
        public static KerningSubTable Load(BinaryReader reader)
        {
            // Kerning subtables will share the same header format. This header is used to identify the format of the subtable and the kind of information it contains:
            // Type   | Field    | Description
            // -------|----------|-----------------------------------------
            // uint16 | version  | Kern subtable version number
            // uint16 | length   | Length of the subtable, in bytes(including this header).
            // uint16 | coverage | What type of information is contained in this table.
            var subVersion = reader.ReadUInt16();
            var length     = reader.ReadUInt16();

            var coverage = KerningCoverage.Read(reader);

            if (coverage.Format == 0)
            {
                return(Format0SubTable.Load(reader, coverage));
            }
            else
            {
                // we don't support versions other than 'Format 0' same as Windows
                return(null);
            }
        }
Beispiel #3
0
 public Format0SubTable(KearningPair[] pairs, KerningCoverage coverage)
     : base(coverage)
     => this.pairs = pairs;
 public KerningSubTable(KerningCoverage coverage)
 {
     this.coverage = coverage;
 }