Table of Contents

Class FontSubset

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

A font holding only some glyphs of another, from FontSubsetter.

public sealed class FontSubset
Inheritance
FontSubset
Inherited Members

Examples

// Keep only the glyphs a page uses, as a PDF writer embeds them: renumbered from 0, with the map to write the text with.
GlyphRun run = new Font(face, 12).Shape("Invoice 2026-10");
FontSubset subset = FontSubsetter.Subset(face, run.Glyphs.ToArray(), new SubsetOptions
{
    FontNamePrefix = "ABCDEF+",
    KeepCmap = false,
});
byte[] fontFile2 = subset.Data.ToArray();
ushort first = subset.GlyphMap[run.Glyphs[0]];

// The face's embedding permissions are reported, never enforced: the writer decides.
bool restricted = face.Embedding.HasFlag(FontEmbedding.Restricted);

Properties

Data

Gets the subset's bytes: an sfnt, or a bare CFF stream.

public ReadOnlyMemory<byte> Data { get; }

Property Value

ReadOnlyMemory<byte>

Format

Gets the format written, never Auto.

public SubsetFormat Format { get; }

Property Value

SubsetFormat

GlyphMap

Gets each kept glyph's new id, by old id; glyphs pulled in by composites and seac accents are included.

public IReadOnlyDictionary<ushort, ushort> GlyphMap { get; }

Property Value

IReadOnlyDictionary<ushort, ushort>

Glyphs

Gets the old id of each new glyph id; gap glyphs of a RetainGlyphIds subset map to themselves.

public IReadOnlyList<ushort> Glyphs { get; }

Property Value

IReadOnlyList<ushort>

Methods

ToTypeface()

Loads the subset as a face.

public Typeface ToTypeface()

Returns

Typeface

The face.