// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.IO; namespace SixLabors.Fonts.Tables { /// /// Represents a table record entry in the font directory. /// Each record contains the tag, checksum, offset, and length of a font table. /// /// internal class TableHeader { /// /// Initializes a new instance of the class. /// /// The four-byte table tag identifier. /// The checksum for the table. /// The byte offset of the table from the beginning of the font file. /// The length of the table in bytes. public TableHeader(string tag, uint checkSum, uint offset, uint len) { this.Tag = tag; this.CheckSum = checkSum; this.Offset = offset; this.Length = len; } /// /// Gets the four-byte table tag identifier (e.g. "head", "glyf", "cmap"). /// public string Tag { get; } /// /// Gets the byte offset of the table from the beginning of the font file. /// public uint Offset { get; } /// /// Gets the checksum for the table, used to verify table integrity. /// public uint CheckSum { get; } /// /// Gets the length of the table data in bytes. /// public uint Length { get; } /// /// Reads a from the given reader. /// /// The binary reader positioned at the table record. /// The parsed . public static TableHeader Read(BigEndianBinaryReader reader) => new TableHeader( reader.ReadTag(), reader.ReadUInt32(), reader.ReadOffset32(), reader.ReadUInt32()); /// /// Creates a positioned at the start of this table's data. /// /// The font file stream. /// A reader positioned at the table data. public virtual BigEndianBinaryReader CreateReader(Stream stream) { stream.Seek(this.Offset, SeekOrigin.Begin); return new BigEndianBinaryReader(stream, true); } } }