/// <summary> Creates a new math variants table by reading it from the specified stream. </summary> /// <param name="reader"> The correctly positioned stream to read from. </param> public VariantsTable(BinaryReader reader) { Contract.Requires(reader != null); long start = reader.BaseStream.Position;//the index in the reader of the start of this variants table //gather all elements in this variants MinConnectorOverlap = reader.ReadUInt16(); uint verticalGlyphCoverageOffset = reader.ReadUInt16EvenThoughSpecsSays32(); uint horizontalGlyphCoverageOffset = reader.ReadUInt16EvenThoughSpecsSays32(); //get the offsets where the glyph constructions are var verticalGlyphOffsets = new uint[reader.ReadUInt16()]; var horizontalGlyphOffsets = new uint[reader.ReadUInt16()]; for (int i = 0; i < verticalGlyphOffsets.Length; i++) { verticalGlyphOffsets[i] = reader.ReadUInt16EvenThoughSpecsSays32(); } for (int i = 0; i < horizontalGlyphOffsets.Length; i++) { horizontalGlyphOffsets[i] = reader.ReadUInt16EvenThoughSpecsSays32(); } //read the glyph constructions var verticalGlyphConstructions = new GlyphConstruction[verticalGlyphOffsets.Length]; var horizontalGlyphConstructions = new GlyphConstruction[horizontalGlyphOffsets.Length]; for (int i = 0; i < verticalGlyphOffsets.Length; i++) { reader.BaseStream.Position = start + verticalGlyphOffsets[i]; verticalGlyphConstructions[i] = new GlyphConstruction(reader); } for (int i = 0; i < horizontalGlyphOffsets.Length; i++) { reader.BaseStream.Position = start + horizontalGlyphOffsets[i]; horizontalGlyphConstructions[i] = new GlyphConstruction(reader); } //get coverages at their locations: reader.BaseStream.Position = start + verticalGlyphCoverageOffset; VerticalCoverage = reader.ReadCoverageTable(); reader.BaseStream.Position = start + horizontalGlyphCoverageOffset; HorizontalCoverage = reader.ReadCoverageTable(); }
/// <summary> Creates a new italics correction info table by reading it from the specified stream. </summary> /// <param name="reader"> The correctly positioned stream to read from. </param> public ItalicsCorrectionInfoTable(BinaryReader reader) { Contract.Requires(reader != null); long start = reader.BaseStream.Position;//the start of this correction info table uint offsetToCoverageTable = reader.ReadUInt16EvenThoughSpecsSays32(); //read corrections var corrections = new short[reader.ReadUInt16()]; for (int i = 0; i < corrections.Length; i++) { corrections[i] = reader.ReadValueRecord(); } Corrections = new ReadOnlyCollection<short>(corrections); //read coverage table reader.BaseStream.Position = start + offsetToCoverageTable; CoverageTable = reader.ReadCoverageTable(); }
/// <summary> Creates a new math glyph info by reading it from the specified stream. </summary> /// <param name="reader"> The correctly positioned stream to read from. </param> public KernInfoTable(BinaryReader reader) { Contract.Requires(reader != null); long start = reader.BaseStream.Position; uint coverageOffset = reader.ReadUInt16EvenThoughSpecsSays32(); int count = reader.ReadInt16(); var backingArray = new KernInfoRecord[count]; for (int i = 0; i < count; i++) { backingArray[i] = new KernInfoRecord(reader, start); } KernInfoRecords = new ReadOnlyCollection<KernInfoRecord>(backingArray); if (coverageOffset != 0) { reader.BaseStream.Position = start + coverageOffset; Coverage = reader.ReadCoverageTable(); } }