public static Mark2ArrayTable CreateFrom(BinaryReader reader, long beginAt, ushort classCount) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--- var mark2ArrTable = new Mark2ArrayTable(); ushort mark2Count = reader.ReadUInt16(); mark2ArrTable.mark2Records = new Mark2Record[mark2Count]; for (int i = 0; i < mark2Count; ++i) { mark2ArrTable.mark2Records[i] = new Mark2Record(Utils.ReadInt16Array(reader, classCount)); } //read mark2 anchor for (int i = 0; i < mark2Count; ++i) { short[] offsets = mark2ArrTable.mark2Records[i].offsets; AnchorPoint[] anchors = mark2ArrTable.mark2Records[i].anchorPoints; int offsetCount = anchors.Length; for (int c = 0; c < offsetCount; ++c) { anchors[c] = AnchorPoint.CreateFrom(reader, beginAt + offsets[c]); } } return(mark2ArrTable); }
public static BaseArrayTable CreateFrom(BinaryReader reader, long beginAt, ushort classCount) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--- var baseArrTable = new BaseArrayTable(); ushort baseCount = reader.ReadUInt16(); baseArrTable.records = new BaseRecord[baseCount]; // Read all baseAnchorOffsets in one go ushort[] baseAnchorOffsets = Utils.ReadUInt16Array(reader, classCount * baseCount); for (int i = 0; i < baseCount; ++i) { BaseRecord baseRec = new BaseRecord(classCount); //each base has anchor point for mark glyph'class for (int n = 0; n < classCount; ++n) { ushort offset = baseAnchorOffsets[i * classCount + n]; if (offset <= 0) { //TODO: review here //bug? continue; } baseRec.anchors[n] = AnchorPoint.CreateFrom(reader, beginAt + offset); } baseArrTable.records[i] = baseRec; } return(baseArrTable); }
void ReadFrom(BinaryReader reader) { long markTableBeginAt = reader.BaseStream.Position; ushort markCount = reader.ReadUInt16(); records = new MarkRecord[markCount]; for (int i = 0; i < markCount; ++i) { //1 mark : 1 anchor records[i] = new MarkRecord( reader.ReadUInt16(), //mark class reader.ReadInt16()); //offset to anchor table } //--------------------------- //read anchor anchorPoints = new AnchorPoint[markCount]; for (int i = 0; i < markCount; ++i) { MarkRecord markRec = records[i]; //bug? if (markRec.offset < 0) { //TODO: review here //found err on Tahoma continue; } //read table detail anchorPoints[i] = AnchorPoint.CreateFrom(reader, markTableBeginAt + markRec.offset); } }
///Mark2Array table //Value Type Description //uint16 Mark2Count Number of Mark2 records //struct Mark2Record[Mark2Count] Array of Mark2 records-in Coverage order //Each Mark2Record contains an array of offsets to Anchor tables (Mark2Anchor). //The array of zero-based offsets, measured from the beginning of the Mark2Array table, //defines the entire set of Mark2 attachment points used to attach Mark1 glyphs to a specific Mark2 glyph. //The Anchor tables in the Mark2Anchor array are ordered by Mark1 class value. //A Mark2Record declares one Anchor table for each mark class (including Class 0) //identified in the MarkRecords of the MarkArray. //Each Anchor table specifies one Mark2 attachment point used to attach all //the Mark1 glyphs in a particular class to the Mark2 glyph. //Mark2Record //Value Type Description //Offset16 Mark2Anchor[ClassCount] Array of offsets (one per class) to Anchor tables-from beginning of Mark2Array table-zero-based array public static Mark2ArrayTable CreateFrom(BinaryReader reader, long beginAt, ushort classCount) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--- ushort mark2Count = reader.ReadUInt16(); ushort[] offsets = Utils.ReadUInt16Array(reader, mark2Count * classCount); //read mark2 anchors AnchorPoint[] anchors = new AnchorPoint[mark2Count * classCount]; for (int i = 0; i < mark2Count * classCount; ++i) { anchors[i] = AnchorPoint.CreateFrom(reader, beginAt + offsets[i]); } return(new Mark2ArrayTable(classCount, anchors)); }
public static BaseArrayTable CreateFrom(BinaryReader reader, long beginAt, ushort classCount) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--- var baseArrTable = new BaseArrayTable(); ushort baseCount = reader.ReadUInt16(); BaseRecord[] baseRecs = baseArrTable.records = new BaseRecord[baseCount]; for (int i = 0; i < baseCount; ++i) { baseArrTable.records[i] = new BaseRecord(Utils.ReadInt16Array(reader, classCount)); } //read anchor table for (int i = 0; i < baseCount; ++i) { short[] offsets = baseRecs[i].offsets; #if DEBUG if (classCount != offsets.Length) { throw new NotSupportedException(); } #endif //each base has anchor point for mark glyph'class AnchorPoint[] anchors = baseRecs[i].anchors = new AnchorPoint[classCount]; for (int n = 0; n < classCount; ++n) { short offset = offsets[n]; if (offset < 0) { //TODO: review here //bug? continue; } anchors[n] = AnchorPoint.CreateFrom(reader, beginAt + offsets[n]); } } return(baseArrTable); }