Ejemplo n.º 1
0
        public static TupleVariationHeader Read(BinaryReader reader, int axisCount)
        {
            TupleVariationHeader header = new TupleVariationHeader();

            header.variableDataSize = reader.ReadUInt16();
            ushort tupleIndex = reader.ReadUInt16();
            int    flags      = (tupleIndex >> 12) & 0xF;                      //The high 4 bits are flags(see below).

            header.flags = flags;                                              //The high 4 bits are flags(see below).
            header.indexToSharedTupleRecArray = (ushort)(tupleIndex & 0x0FFF); // The low 12 bits are an index into a shared tuple records array.


            if ((flags & ((int)TupleIndexFormat.EMBEDDED_PEAK_TUPLE >> 12)) == ((int)TupleIndexFormat.EMBEDDED_PEAK_TUPLE >> 12))
            {
                //TODO:...
                header.peakTuple = TupleRecord.ReadTupleRecord(reader, axisCount);
            }
            if ((flags & ((int)TupleIndexFormat.INTERMEDIATE_REGION >> 12)) == ((int)TupleIndexFormat.INTERMEDIATE_REGION >> 12))
            {
                //TODO:...
                header.intermediateStartTuple = TupleRecord.ReadTupleRecord(reader, axisCount);
                header.intermediateEndTuple   = TupleRecord.ReadTupleRecord(reader, axisCount);
            }

            return(header);
        }
Ejemplo n.º 2
0
        void ReadSharedTupleArray(BinaryReader reader, ushort sharedTupleCount)
        {
            //-------------
            //Shared tuples array
            //-------------
            //The shared tuples array provides a set of variation-space positions
            //that can be referenced by variation data for any glyph.
            //The shared tuples array follows the GlyphVariationData offsets array
            //at the end of the 'gvar' header.
            //This data is simply an array of tuple records, each representing a position in the font’s variation space.

            //Shared tuples array:
            //Type            Name                            Description
            //TupleRecord     sharedTuples[sharedTupleCount]  Array of tuple records shared across all glyph variation data tables.

            //Tuple records that are in the shared array or
            //that are contained directly within a given glyph variation data table
            //use 2.14 values to represent normalized coordinate values.
            //See the Common Table Formats chapter for details.

            //

            //Tuple Records
            //https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats
            //The tuple variation store formats make reference to regions within the font’s variation space using tuple records.
            //These references identify positions in terms of normalized coordinates, which use F2DOT14 values.
            //Tuple record(F2DOT14):
            //Type Name    Description
            //F2DOT14     coordinates[axisCount]  Coordinate array specifying a position within the font’s variation space.
            //                                    The number of elements must match the axisCount specified in the 'fvar' table.


            TupleRecord[] tupleRecords = new TupleRecord[sharedTupleCount];
            for (int t = 0; t < sharedTupleCount; ++t)
            {
                tupleRecords[t] = TupleRecord.ReadTupleRecord(reader, axisCount);
            }

            _sharedTuples = tupleRecords;
        }