public static PosClassSetTable CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //-------- var posClassSetTable = new PosClassSetTable(); posClassSetTable.ReadFrom(reader); return(posClassSetTable); }
/// <summary> /// LookupType 8: Chaining Contextual Positioning Subtable /// </summary> /// <param name="reader"></param> void ReadLookupType8(BinaryReader reader) { long thisLookupTablePos = reader.BaseStream.Position; int j = subTableOffsets.Length; for (int i = 0; i < j; ++i) { //move to read pos long subTableStartAt = lookupTablePos + subTableOffsets[i]; reader.BaseStream.Seek(subTableStartAt, SeekOrigin.Begin); //----------------------- ushort format = reader.ReadUInt16(); switch (format) { default: throw new NotSupportedException(); case 1: { //Chaining Context Positioning Format 1: Simple Chaining Context Glyph Positioning // USHORT PosFormat Format identifier-format = 1 //Offset Coverage Offset to Coverage table-from beginning of ContextPos subtable //USHORT ChainPosRuleSetCount Number of ChainPosRuleSet tables //Offset ChainPosRuleSet //[ChainPosRuleSetCount] Array of offsets to ChainPosRuleSet tables-from beginning of ContextPos subtable-ordered by Coverage Index short coverageOffset = reader.ReadInt16(); ushort chainPosRuleSetCount = reader.ReadUInt16(); short[] chainPosRuleSetOffsetList = Utils.ReadInt16Array(reader, chainPosRuleSetCount); LkSubTableType8Fmt1 subTable = new LkSubTableType8Fmt1(); subTable.PosRuleSetTables = CreateMultiplePosRuleSetTables(subTableStartAt, chainPosRuleSetOffsetList, reader); subTable.CoverageTable = CoverageTable.CreateFrom(reader, subTableStartAt + coverageOffset); //---------- subTables.Add(subTable); } break; case 2: { //Chaining Context Positioning Format 2: Class-based Chaining Context Glyph Positioning //USHORT PosFormat Format identifier-format = 2 //Offset Coverage Offset to Coverage table-from beginning of ChainContextPos subtable //Offset BacktrackClassDef Offset to ClassDef table containing backtrack sequence context-from beginning of ChainContextPos subtable //Offset InputClassDef Offset to ClassDef table containing input sequence context-from beginning of ChainContextPos subtable //Offset LookaheadClassDef Offset to ClassDef table containing lookahead sequence context-from beginning of ChainContextPos subtable //USHORT ChainPosClassSetCnt Number of ChainPosClassSet tables //Offset ChainPosClassSet //[ChainPosClassSetCnt] Array of offsets to ChainPosClassSet tables-from beginning of ChainContextPos subtable-ordered by input class-may be NULL short coverageOffset = reader.ReadInt16(); short backTrackClassDefOffset = reader.ReadInt16(); short inpuClassDefOffset = reader.ReadInt16(); short lookadheadClassDefOffset = reader.ReadInt16(); ushort chainPosClassSetCnt = reader.ReadUInt16(); short[] chainPosClassSetOffsetArray = Utils.ReadInt16Array(reader, chainPosClassSetCnt); LkSubTableType8Fmt2 subTable = new LkSubTableType8Fmt2(chainPosClassSetOffsetArray); subTable.BacktrackClassDefOffset = backTrackClassDefOffset; subTable.InputClassDefOffset = inpuClassDefOffset; subTable.LookaheadClassDefOffset = lookadheadClassDefOffset; //---------- PosClassSetTable[] posClassSetTables = new PosClassSetTable[chainPosClassSetCnt]; subTable.PosClassSetTables = posClassSetTables; for (int n = 0; n < chainPosClassSetCnt; ++n) { posClassSetTables[n] = PosClassSetTable.CreateFrom(reader, subTableStartAt + chainPosClassSetOffsetArray[i]); } //---------- subTable.CoverageTable = CoverageTable.CreateFrom(reader, subTableStartAt + coverageOffset); //---------- subTables.Add(subTable); //---------- } break; case 3: { //Chaining Context Positioning Format 3: Coverage-based Chaining Context Glyph Positioning //USHORT PosFormat Format identifier-format = 3 //USHORT BacktrackGlyphCount Number of glyphs in the backtracking sequence //Offset Coverage[BacktrackGlyphCount] Array of offsets to coverage tables in backtracking sequence, in glyph sequence order //USHORT InputGlyphCount Number of glyphs in input sequence //Offset Coverage[InputGlyphCount] Array of offsets to coverage tables in input sequence, in glyph sequence order //USHORT LookaheadGlyphCount Number of glyphs in lookahead sequence //Offset Coverage[LookaheadGlyphCount] Array of offsets to coverage tables in lookahead sequence, in glyph sequence order //USHORT PosCount Number of PosLookupRecords //struct PosLookupRecord[PosCount] Array of PosLookupRecords,in design order var subTable = new LkSubTableType8Fmt3(); // ushort backtrackGlyphCount = reader.ReadUInt16(); short[] backtrackCoverageOffsets = Utils.ReadInt16Array(reader, backtrackGlyphCount); ushort inputGlyphCount = reader.ReadUInt16(); short[] inputGlyphCoverageOffsets = Utils.ReadInt16Array(reader, inputGlyphCount); // ushort lookaheadGlyphCount = reader.ReadUInt16(); short[] lookaheadCoverageOffsets = Utils.ReadInt16Array(reader, lookaheadGlyphCount); // ushort posCount = reader.ReadUInt16(); subTable.PosLookupRecords = CreateMultiplePosLookupRecords(reader, posCount); //-------------- subTable.BacktrackCoverages = CoverageTable.CreateMultipleCoverageTables(subTableStartAt, backtrackCoverageOffsets, reader); subTable.InputGlyphCoverages = CoverageTable.CreateMultipleCoverageTables(subTableStartAt, inputGlyphCoverageOffsets, reader); subTable.LookaheadCoverages = CoverageTable.CreateMultipleCoverageTables(subTableStartAt, lookaheadCoverageOffsets, reader); subTables.Add(subTable); } break; } } }
/// <summary> /// Lookup Type 7: Contextual Positioning Subtables /// </summary> /// <param name="reader"></param> void ReadLookupType7(BinaryReader reader) { long thisLookupTablePos = reader.BaseStream.Position; int j = subTableOffsets.Length; for (int i = 0; i < j; ++i) { //move to read pos long subTableStartAt = lookupTablePos + subTableOffsets[i]; reader.BaseStream.Seek(subTableStartAt, SeekOrigin.Begin); //----------------------- ushort format = reader.ReadUInt16(); switch (format) { default: throw new NotSupportedException(); case 1: { //Context Positioning Subtable: Format 1 //ContextPosFormat1 subtable: Simple context positioning //Value Type Description //USHORT PosFormat Format identifier-format = 1 //Offset Coverage Offset to Coverage table-from beginning of ContextPos subtable //USHORT PosRuleSetCount Number of PosRuleSet tables //Offset PosRuleSet[PosRuleSetCount] // short coverageOffset = reader.ReadInt16(); ushort posRuleSetCount = reader.ReadUInt16(); short[] posRuleSetOffsets = Utils.ReadInt16Array(reader, posRuleSetCount); LkSubTableType7Fmt1 subTable = new LkSubTableType7Fmt1(); subTable.PosRuleSetTables = CreateMultiplePosRuleSetTables(subTableStartAt, posRuleSetOffsets, reader); subTable.CoverageTable = CoverageTable.CreateFrom(reader, subTableStartAt + coverageOffset); //----------- subTables.Add(subTable); } break; case 2: { //Context Positioning Subtable: Format 2 //USHORT PosFormat Format identifier-format = 2 //Offset Coverage Offset to Coverage table-from beginning of ContextPos subtable //Offset ClassDef Offset to ClassDef table-from beginning of ContextPos subtable //USHORT PosClassSetCnt Number of PosClassSet tables //Offset PosClassSet //[PosClassSetCnt] Array of offsets to PosClassSet tables-from beginning of ContextPos subtable-ordered by class-may be NULL short coverageOffset = reader.ReadInt16(); short classDefOffset = reader.ReadInt16(); ushort posClassSetCount = reader.ReadUInt16(); short[] posClassSetOffsets = Utils.ReadInt16Array(reader, posClassSetCount); var subTable = new LkSubTableType7Fmt2(); subTable.ClassDefOffset = classDefOffset; //---------- PosClassSetTable[] posClassSetTables = new PosClassSetTable[posClassSetCount]; subTable.PosClassSetTables = posClassSetTables; for (int n = 0; n < posClassSetCount; ++n) { posClassSetTables[n] = PosClassSetTable.CreateFrom(reader, coverageOffset); } //---------- subTable.CoverageTable = CoverageTable.CreateFrom(reader, subTableStartAt + coverageOffset); //---------- subTables.Add(subTable); //---------- } break; case 3: { //ContextPosFormat3 subtable: Coverage-based context glyph positioning //Value Type Description //USHORT PosFormat Format identifier-format = 3 //USHORT GlyphCount Number of glyphs in the input sequence //USHORT PosCount Number of PosLookupRecords //Offset Coverage[GlyphCount] Array of offsets to Coverage tables-from beginning of ContextPos subtable //struct PosLookupRecord[PosCount] Array of positioning lookups-in design order var subTable = new LkSubTableType7Fmt3(); ushort glyphCount = reader.ReadUInt16(); ushort posCount = reader.ReadUInt16(); //read each lookahead record short[] coverageOffsets = Utils.ReadInt16Array(reader, glyphCount); subTable.PosLookupRecords = CreateMultiplePosLookupRecords(reader, posCount); subTable.CoverageTables = CoverageTable.CreateMultipleCoverageTables(subTableStartAt, coverageOffsets, reader); //---------- subTables.Add(subTable); //---------- } break; } } }
public static PosClassSetTable CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //-------- var posClassSetTable = new PosClassSetTable(); posClassSetTable.ReadFrom(reader); return posClassSetTable; }