public static CoverageTable CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--------------------------------------------------- var coverageTable = new CoverageTable(); //1. format switch (coverageTable._format = reader.ReadUInt16()) { default: throw new NotSupportedException(); case 1: { //CoverageFormat1 table: Individual glyph indices ushort glyphCount = reader.ReadUInt16(); //GlyphID GlyphArray[GlyphCount] Array of GlyphIDs-in numerical order *** ushort[] orderedGlyphIdList = new ushort[glyphCount]; for (int i = 0; i < glyphCount; ++i) { orderedGlyphIdList[i] = reader.ReadUInt16(); } coverageTable.orderedGlyphIdList = orderedGlyphIdList; } break; case 2: { //CoverageFormat2 table: Range of glyphs ushort rangeCount = reader.ReadUInt16(); RangeRecord[] ranges = new RangeRecord[rangeCount]; for (int i = 0; i < rangeCount; ++i) { ranges[i] = new RangeRecord( reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16()); } coverageTable.ranges = ranges; coverageTable.UpdateRangeOffsets(); } break; } return(coverageTable); }
public static CoverageTable CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //--------------------------------------------------- var coverageTable = new CoverageTable(); //CoverageFormat1 table: Individual glyph indices //Type Name Description //uint16 CoverageFormat Format identifier-format = 1 //uint16 GlyphCount Number of glyphs in the GlyphArray //uint16 GlyphArray[GlyphCount] Array of glyph IDs — in numerical order //--------------------------------- //CoverageFormat2 table: Range of glyphs //Type Name Description //uint16 CoverageFormat Format identifier-format = 2 //uint16 RangeCount Number of RangeRecords //struct RangeRecord[RangeCount] Array of glyph ranges — ordered by StartGlyphID. //------------ //RangeRecord //---------- //Type Name Description //uint16 StartGlyphID First glyph ID in the range //uint16 EndGlyphID Last glyph ID in the range //uint16 StartCoverageIndex Coverage Index of first glyph ID in range //---------- switch (coverageTable._format = reader.ReadUInt16()) { default: throw new NotSupportedException(); case 1: //CoverageFormat1 table: Individual glyph indices { ushort glyphCount = reader.ReadUInt16(); ushort[] orderedGlyphIdList = new ushort[glyphCount]; // for (int i = 0; i < glyphCount; ++i) { orderedGlyphIdList[i] = reader.ReadUInt16(); } coverageTable.orderedGlyphIdList = orderedGlyphIdList; } break; case 2: //CoverageFormat2 table: Range of glyphs { ushort rangeCount = reader.ReadUInt16(); RangeRecord[] ranges = new RangeRecord[rangeCount]; for (int i = 0; i < rangeCount; ++i) { ranges[i] = new RangeRecord( reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16()); } coverageTable.ranges = ranges; coverageTable.UpdateRangeOffsets(); } break; } return(coverageTable); }