Class OpenTypeTableDirectory
Parses the OpenType table directory and provides helpers for reading raw table bytes.
Inherited Members
Namespace: DRIT.Drawing.Font.IO
Assembly: DRIT.Drawing.dll
Syntax
public static class OpenTypeTableDirectory
Remarks
The table directory immediately follows the 12-byte offset table in an sfnt file. Each entry is 16 bytes: 4-byte tag, 4-byte checksum, 4-byte offset, 4-byte length.
Methods
ComputeChecksum(byte[])
Computes the OpenType table checksum for a block of bytes. Algorithm: sum all 32-bit big-endian words (zero-padding the last word if needed), modulo 2^32.
Declaration
public static uint ComputeChecksum(byte[] tableData)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | tableData |
Returns
| Type | Description |
|---|---|
| uint |
Remarks
The table directory immediately follows the 12-byte offset table in an sfnt file. Each entry is 16 bytes: 4-byte tag, 4-byte checksum, 4-byte offset, 4-byte length.
Parse(FontBinaryReader)
Reads the offset table and the complete table directory from the current
position of reader (expected to be at byte 0 of the font).
Declaration
public static (OpenTypeOffsetTable Header, IReadOnlyDictionary<string, OpenTypeTableRecord> Records) Parse(FontBinaryReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| FontBinaryReader | reader |
Returns
| Type | Description |
|---|---|
| (OpenTypeOffsetTable Header, IReadOnlyDictionary<string, OpenTypeTableRecord> Records) | A tuple of the parsed OpenTypeOffsetTable header and a case-sensitive dictionary mapping each table tag to its OpenTypeTableRecord. |
Remarks
The table directory immediately follows the 12-byte offset table in an sfnt file. Each entry is 16 bytes: 4-byte tag, 4-byte checksum, 4-byte offset, 4-byte length.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when the sfnt magic bytes are not recognised as a supported font format. |
ReadAllTableBytes(FontBinaryReader, IReadOnlyDictionary<string, OpenTypeTableRecord>)
Reads the raw bytes of every table listed in records
and returns them keyed by tag.
Declaration
public static IReadOnlyDictionary<string, byte[]> ReadAllTableBytes(FontBinaryReader reader, IReadOnlyDictionary<string, OpenTypeTableRecord> records)
Parameters
| Type | Name | Description |
|---|---|---|
| FontBinaryReader | reader | |
| IReadOnlyDictionary<string, OpenTypeTableRecord> | records |
Returns
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, byte[]> |
Remarks
The table directory immediately follows the 12-byte offset table in an sfnt file. Each entry is 16 bytes: 4-byte tag, 4-byte checksum, 4-byte offset, 4-byte length.
ReadTableBytes(FontBinaryReader, OpenTypeTableRecord)
Seeks to a table's data and reads its raw bytes.
Declaration
public static byte[] ReadTableBytes(FontBinaryReader reader, OpenTypeTableRecord record)
Parameters
| Type | Name | Description |
|---|---|---|
| FontBinaryReader | reader | |
| OpenTypeTableRecord | record |
Returns
| Type | Description |
|---|---|
| byte[] |
Remarks
The table directory immediately follows the 12-byte offset table in an sfnt file. Each entry is 16 bytes: 4-byte tag, 4-byte checksum, 4-byte offset, 4-byte length.