Table of Contents

Struct FontTag

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

A four-byte OpenType tag, such as the table tag glyf or the feature tag kern.

public readonly record struct FontTag : IEquatable<FontTag>
Implements
Inherited Members

Examples

// One face from a file; a collection takes an index. The bytes are read once and every table is parsed when first needed.
Typeface face = Typeface.FromFile(FontFile);
Console.WriteLine($"{face.FamilyName} {face.SubfamilyName}, {face.GlyphCount} glyphs, {face.UnitsPerEm} units per em");

// What a file holds, from its header alone.
FontProbe probe = FontLoader.Probe(File.ReadAllBytes(FontFile));
Console.WriteLine($"{probe.Kind}, {probe.FaceCount} face(s), {probe.Outlines} outlines");

// Damaged fonts load leniently with diagnostics; Strict throws instead.
var seen = new List<EgamiDiagnostic>();
var options = new FontLoadOptions { Context = EgamiContext.Default with { Diagnostics = seen.Add } };
Typeface lenient = Typeface.FromMemory(File.ReadAllBytes(FontFile), 0, options);

Constructors

FontTag(string)

Initializes a tag from its text, such as "OS/2"; shorter text is padded with spaces.

public FontTag(string tag)

Parameters

tag string

One to four characters in the range 0x20 to 0x7E.

Exceptions

ArgumentException

tag is empty, longer than four characters or not printable ASCII.

FontTag(uint)

A four-byte OpenType tag, such as the table tag glyf or the feature tag kern.

public FontTag(uint Value)

Parameters

Value uint

The tag's four bytes, first byte in the high bits.

Examples

// One face from a file; a collection takes an index. The bytes are read once and every table is parsed when first needed.
Typeface face = Typeface.FromFile(FontFile);
Console.WriteLine($"{face.FamilyName} {face.SubfamilyName}, {face.GlyphCount} glyphs, {face.UnitsPerEm} units per em");

// What a file holds, from its header alone.
FontProbe probe = FontLoader.Probe(File.ReadAllBytes(FontFile));
Console.WriteLine($"{probe.Kind}, {probe.FaceCount} face(s), {probe.Outlines} outlines");

// Damaged fonts load leniently with diagnostics; Strict throws instead.
var seen = new List<EgamiDiagnostic>();
var options = new FontLoadOptions { Context = EgamiContext.Default with { Diagnostics = seen.Add } };
Typeface lenient = Typeface.FromMemory(File.ReadAllBytes(FontFile), 0, options);

Properties

Value

The tag's four bytes, first byte in the high bits.

public uint Value { get; init; }

Property Value

uint

Methods

ToString()

Returns the tag as four characters, such as "OS/2".

public override string ToString()

Returns

string

The text.