示例#1
0
        protected override void ReadContentFrom(BinaryReader reader)
        {
            long beginAt = reader.BaseStream.Position;

            //Horizontal metrics variations table:
            //Type      Name                        Description
            //uint16    majorVersion                Major version number of the horizontal metrics variations table — set to 1.
            //uint16    minorVersion                Minor version number of the horizontal metrics variations table — set to 0.
            //Offset32  itemVariationStoreOffset    Offset in bytes from the start of this table to the item variation store table.
            //Offset32  advanceWidthMappingOffset   Offset in bytes from the start of this table to the delta-set index mapping for advance widths (may be NULL).
            //Offset32  lsbMappingOffset            Offset in bytes from the start of this table to the delta - set index mapping for left side bearings(may be NULL).
            //Offset32  rsbMappingOffset            Offset in bytes from the start of this table to the delta - set index mapping for right side bearings(may be NULL).

            ushort majorVersion              = reader.ReadUInt16();
            ushort minorVersion              = reader.ReadUInt16();
            uint   itemVariationStoreOffset  = reader.ReadUInt32();
            uint   advanceWidthMappingOffset = reader.ReadUInt32();
            uint   lsbMappingOffset          = reader.ReadUInt32();
            uint   rsbMappingOffset          = reader.ReadUInt32();

            //
            //-----------------------------------------

            //itemVariationStore
            reader.BaseStream.Position = beginAt + itemVariationStoreOffset;
            _itemVartionStore          = new ItemVariationStoreTable();
            _itemVartionStore.ReadContentFrom(reader);
        }
示例#2
0
        protected override void ReadContentFrom(BinaryReader reader)
        {
            long startAt = reader.BaseStream.Position;

            //Metrics variations table:
            //Type      Name                Description
            //uint16    majorVersion        Major version number of the metrics variations table — set to 1.
            //uint16    minorVersion        Minor version number of the metrics variations table — set to 0.
            //uint16    (reserved)          Not used; set to 0.
            //uint16    valueRecordSize     The size in bytes of each value record — must be greater than zero.
            //uint16    valueRecordCount    The number of value records — may be zero.
            //Offset16  itemVariationStoreOffset    Offset in bytes from the start of this table to the item variation store table.
            //                                      If valueRecordCount is zero, set to zero;
            //                                      if valueRecordCount is greater than zero, must be greater than zero.
            //ValueRecord valueRecords[valueRecordCount]  Array of value records that identify target items and the associated delta-set index for each.
            //                                           The valueTag records must be in binary order of their valueTag field.

            //-----------
            //
            //The valueRecordSize field indicates the size of each value record.
            //Future, minor version updates of the MVAR table may define compatible extensions to the value record format with additional fields.
            //**Implementations must use the valueRecordSize field to determine the start of each record.**

            //The valueRecords array is an array of value records that identify the target,
            //font -wide measures for which variation adjustment data is provided (target items),
            //and outer and inner delta-set indices for each item into the item variation store data.


            ushort majorVersion             = reader.ReadUInt16();
            ushort minorVersion             = reader.ReadUInt16();
            ushort reserved                 = reader.ReadUInt16();
            ushort valueRecordSize          = reader.ReadUInt16();
            ushort valueRecordCount         = reader.ReadUInt16();
            ushort itemVariationStoreOffset = reader.ReadUInt16();

            valueRecords = new ValueRecord[valueRecordCount];

            for (int i = 0; i < valueRecordCount; ++i)
            {
                long recStartAt = reader.BaseStream.Position;
                valueRecords[i] = new ValueRecord(
                    reader.ReadUInt32(),
                    reader.ReadUInt16(),
                    reader.ReadUInt16()
                    );

                reader.BaseStream.Position = recStartAt + valueRecordSize;//**Implementations must use the valueRecordSize field to determine the start of each record.**
            }

            //
            //item variation store table
            if (valueRecordCount > 0)
            {
                reader.BaseStream.Position = startAt + itemVariationStoreOffset;
                itemVariationStore         = new ItemVariationStoreTable();
                itemVariationStore.ReadContentFrom(reader);
            }
        }