Table of Contents

Interface IRasterizer

Namespace
KernSmith.Rasterizer
Assembly
KernSmith.dll

Rasterizes font glyphs into bitmaps for texture atlas packing.

public interface IRasterizer : IDisposable
Inherited Members

Properties

Capabilities

Describes what this rasterizer backend supports.

IRasterizerCapabilities Capabilities { get; }

Property Value

IRasterizerCapabilities

Methods

GetFontMetrics(RasterOptions)

Returns rasterizer-provided font-wide metrics. Returns null to fall back to TTF table calculation.

RasterizerFontMetrics? GetFontMetrics(RasterOptions options)

Parameters

options RasterOptions

Returns

RasterizerFontMetrics

GetGlyphMetrics(int, RasterOptions)

Gets glyph metrics without rasterizing. Returns null if the glyph is missing from the font.

GlyphMetrics? GetGlyphMetrics(int codepoint, RasterOptions options)

Parameters

codepoint int

The Unicode character code.

options RasterOptions

Size, DPI, and other settings.

Returns

GlyphMetrics?

GetKerningPairs(RasterOptions)

Returns rasterizer-provided kerning pairs already scaled to pixel values. Returns null to fall back to TTF GPOS/kern table parser.

IReadOnlyList<ScaledKerningPair>? GetKerningPairs(RasterOptions options)

Parameters

options RasterOptions

Returns

IReadOnlyList<ScaledKerningPair>

LoadFont(ReadOnlyMemory<byte>, int)

Loads a font from raw file bytes for subsequent rasterization.

void LoadFont(ReadOnlyMemory<byte> fontData, int faceIndex = 0)

Parameters

fontData ReadOnlyMemory<byte>

The font file bytes.

faceIndex int

Which face to use in a .ttc font collection. Usually 0.

LoadSystemFont(string)

Loads a system-installed font by family name for subsequent rasterization. Not all backends support this — the default throws NotSupportedException. Check SupportsSystemFonts before calling.

void LoadSystemFont(string familyName)

Parameters

familyName string

The font family name (e.g., "Arial").

RasterizeAll(IEnumerable<int>, RasterOptions)

Renders multiple characters to bitmaps, skipping any that are missing from the font.

IReadOnlyList<RasterizedGlyph> RasterizeAll(IEnumerable<int> codepoints, RasterOptions options)

Parameters

codepoints IEnumerable<int>

The Unicode character codes to render.

options RasterOptions

Size, DPI, anti-aliasing, and other rendering settings.

Returns

IReadOnlyList<RasterizedGlyph>

RasterizeGlyph(int, RasterOptions)

Renders a single character to a bitmap. Returns null if the glyph is missing from the font.

RasterizedGlyph? RasterizeGlyph(int codepoint, RasterOptions options)

Parameters

codepoint int

The Unicode character code to render.

options RasterOptions

Size, DPI, anti-aliasing, and other rendering settings.

Returns

RasterizedGlyph

SelectColorPalette(int)

Selects a color palette by index for color font rendering. Only called when SupportsColorFonts is true.

void SelectColorPalette(int paletteIndex)

Parameters

paletteIndex int

Zero-based palette index.

SetVariationAxes(IReadOnlyList<VariationAxis>, Dictionary<string, float>)

Applies variable font axis values. Only called when SupportsVariableFonts is true.

void SetVariationAxes(IReadOnlyList<VariationAxis> fvarAxes, Dictionary<string, float> userAxes)

Parameters

fvarAxes IReadOnlyList<VariationAxis>

The axes defined in the font's fvar table, in order.

userAxes Dictionary<string, float>

User-specified axis tag/value pairs (e.g., "wght" = 700).