private IndexToLocationTable CreateLocaTable(GlyfDataTable glyfTable) { DirectoryEntry entry = new DirectoryEntry(TableNames.Loca); IndexToLocationTable loca = new IndexToLocationTable(entry, glyfTable.Count); uint offset = 0; for (int i = 0; i < glyfTable.Count; i++) { loca.AddOffset(offset); offset += glyfTable[i].Length; } // Add trailer offset loca.AddOffset(offset); return loca; }
private HorizontalMetricsTable CreateHmtxTable(GlyfDataTable glyfTable) { // Fetches horizontal metrics for all glyphs HorizontalMetricsTable hmtxOld = reader.GetHorizontalMetricsTable(); DirectoryEntry entry = new DirectoryEntry(TableNames.Hmtx); HorizontalMetricsTable hmtx = new HorizontalMetricsTable(entry, glyfTable.Count); // Copy required horizontal metrics. IndexMappings mappings = reader.IndexMappings; foreach (int subsetIndex in mappings.SubsetIndices) { int glyphIndex = mappings.GetGlyphIndex(subsetIndex); hmtx[subsetIndex] = hmtxOld[glyphIndex].Clone(); } return hmtx; }
protected internal void Read(FontFileStream stream) { // Skip sfnt version (0x00010000 for version 1.0). stream.Skip(PrimitiveSizes.Fixed); // Number of tables int numTables = stream.ReadUShort(); // Skip searchRange, entrySelector and rangeShift entries (3 x ushort) stream.Skip(PrimitiveSizes.UShort*3); directoryEntries = new Hashtable(numTables); for (int i = 0; i < numTables; i++) { DirectoryEntry entry = new DirectoryEntry( stream.ReadTag(), // 4-byte identifier. stream.ReadULong(), // CheckSum for this table. stream.ReadULong(), // Offset from beginning of TrueType font file. stream.ReadULong() // Length of this table. ); directoryEntries.Add(entry.TableName, entry); } }
/// <summary> /// Class constructor. /// </summary> /// <param name="entry"></param> public KerningTable(DirectoryEntry entry) : base(TableNames.Kern, entry) {}
/// <summary> /// Class constructor. /// </summary> /// <param name="entry"></param> public PostTable(DirectoryEntry entry) : base(TableNames.Post, entry) {}
/// <summary> /// Class constructor /// </summary> /// <param name="tableName">The table name.</param> /// <param name="entry">Table directory entry.</param> public FontTable(string tableName, DirectoryEntry entry) { this.directoryEntry = entry; }
/// <summary> /// Class constructor. /// </summary> /// <param name="entry"></param> public HeaderTable(DirectoryEntry entry) : base(TableNames.Head, entry) {}
/// <summary> /// Class constructor. /// </summary> /// <param name="entry"></param> public HorizontalHeaderTable(DirectoryEntry entry) : base(TableNames.Hhea, entry) {}
/// <summary> /// Initialises a new instance of the /// <see cref="IndexToLocationTable"/> class. /// </summary> /// <param name="entry"></param> public IndexToLocationTable(DirectoryEntry entry) : base(TableNames.Loca, entry) {}
/// <summary> /// Initialises a new instance of the HorizontalMetricsTable class. /// </summary> /// <param name="entry"></param> public HorizontalMetricsTable(DirectoryEntry entry, int numMetrics) : base(TableNames.Hmtx, entry) { this.metrics = new ArrayList(numMetrics); }
/// <summary> /// Initialises a new instance of the /// <see cref="HorizontalMetricsTable"/> class. /// </summary> /// <param name="entry"></param> public HorizontalMetricsTable(DirectoryEntry entry) : base(TableNames.Hmtx, entry) {}
/// <summary> /// Creates an instance of the <see cref="GlyfDataTable"/> class. /// </summary> /// <param name="entry"></param> public GlyfDataTable(DirectoryEntry entry) : base(TableNames.Glyf, entry) { this.glyphDescriptions = new SortedList(); }
public NameTable(DirectoryEntry entry) : base(TableNames.Name, entry) {}
public OS2Table(DirectoryEntry entry) : base(TableNames.Os2, entry) {}
/// <summary> /// Initialises a new instance of the IndexToLocationTable class. /// </summary> /// <param name="entry"></param> public IndexToLocationTable(DirectoryEntry entry, int numOffsets) : base(TableNames.Loca, entry) { this.offsets = new ArrayList(numOffsets); }
/// <summary> /// Sets the stream position to the offset in the supplied directory /// entry. Also ensures that the FontFileStream has enough bytes /// available to read a font table. Throws an exception if this /// condition is not met. /// </summary> /// <param name="entry"></param> /// <exception cref="ArgumentException"> /// If the supplied stream does not contain enough data. /// </exception> private void OffsetStream(DirectoryEntry entry) { stream.Position = entry.Offset; if ((stream.Position + entry.Length) > stream.Length) { string msg = String.Format( "Error reading table '{0}'. Expected {1} bytes, current position {2}, stream length {3}", entry.TableName, entry.Length, stream.Position, stream.Length); throw new ArgumentException(msg); } }
/// <summary> /// Initialises a new instance of the <see cref="MaximumProfileTable"/> /// class. /// </summary> /// <param name="entry"></param> public MaximumProfileTable(DirectoryEntry entry) : base(TableNames.Maxp, entry) {}