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
Methods
GetFontMetrics(RasterOptions)
Returns rasterizer-provided font-wide metrics. Returns null to fall back to TTF table calculation.
RasterizerFontMetrics? GetFontMetrics(RasterOptions options)
Parameters
optionsRasterOptions
Returns
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
codepointintThe Unicode character code.
optionsRasterOptionsSize, DPI, and other settings.
Returns
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
optionsRasterOptions
Returns
LoadFont(ReadOnlyMemory<byte>, int)
Loads a font from raw file bytes for subsequent rasterization.
void LoadFont(ReadOnlyMemory<byte> fontData, int faceIndex = 0)
Parameters
fontDataReadOnlyMemory<byte>The font file bytes.
faceIndexintWhich 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
familyNamestringThe 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
codepointsIEnumerable<int>The Unicode character codes to render.
optionsRasterOptionsSize, DPI, anti-aliasing, and other rendering settings.
Returns
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
codepointintThe Unicode character code to render.
optionsRasterOptionsSize, DPI, anti-aliasing, and other rendering settings.
Returns
SelectColorPalette(int)
Selects a color palette by index for color font rendering. Only called when SupportsColorFonts is true.
void SelectColorPalette(int paletteIndex)
Parameters
paletteIndexintZero-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
fvarAxesIReadOnlyList<VariationAxis>The axes defined in the font's fvar table, in order.
userAxesDictionary<string, float>User-specified axis tag/value pairs (e.g., "wght" = 700).