Table of Contents

Struct FontProbe

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll
public readonly record struct FontProbe : IEquatable<FontProbe>
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

FontProbe(FontFileKind, int, FontOutlines?)

public FontProbe(FontFileKind Kind, int FaceCount, FontOutlines? Outlines)

Parameters

Kind FontFileKind

What the data is.

FaceCount int

The number of faces: 1 for a single font or CFF, the collection's count, 0 when unknown.

Outlines FontOutlines?

How the first face stores outlines, when that can be told from the header.

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

FaceCount

The number of faces: 1 for a single font or CFF, the collection's count, 0 when unknown.

public int FaceCount { get; init; }

Property Value

int

Kind

What the data is.

public FontFileKind Kind { get; init; }

Property Value

FontFileKind

Outlines

How the first face stores outlines, when that can be told from the header.

public FontOutlines? Outlines { get; init; }

Property Value

FontOutlines?