Ejemplo n.º 1
0
        public static FeatureList CreateFrom(BinaryReader reader, long beginAt)
        {
            //https://www.microsoft.com/typography/otspec/chapter2.htm
            //FeatureList table
            //Type  Name    Description
            //USHORT    FeatureCount    Number of FeatureRecords in this table
            //struct    FeatureRecord[FeatureCount]     Array of FeatureRecords-zero-based (first feature has FeatureIndex = 0)-listed alphabetically by FeatureTag
            //FeatureRecord
            //Type  Name    Description
            //Tag   FeatureTag  4-byte feature identification tag
            //Offset    Feature     Offset to Feature table-from beginning of FeatureList
            reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
            //
            FeatureList featureList  = new FeatureList();
            ushort      featureCount = reader.ReadUInt16();

            FeatureRecord[] featureRecords = new FeatureRecord[featureCount];
            for (int i = 0; i < featureCount; ++i)
            {
                //read script record
                featureRecords[i] = new FeatureRecord(
                    reader.ReadUInt32(), //feature tag
                    reader.ReadInt16()); //offset
            }
            //read each feature table
            FeatureTable[] featureTables = featureList.featureTables = new FeatureTable[featureCount];
            for (int i = 0; i < featureCount; ++i)
            {
                FeatureRecord frecord = featureRecords[i];
                (featureTables[i] = FeatureTable.CreateFrom(reader, beginAt + frecord.offset)).FeatureTag = frecord.featureTag;
            }
            return(featureList);
        }