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
RasterizeOutlineLayer(int, RasterOptions, int, OutlineShape, float)
Renders the outline layer of a character for Vector: the coverage
of the glyph dilated by width pixels — everything
RasterizeGlyph(int, RasterOptions) would draw for the same options, plus every
point within width pixels of its contours. The pipeline colors it, backs
the body with it and composites it exactly where its bitmap outline would go — clipped to the
glyph's box grown by width — so the metrics must place the bitmap in the
same pen-relative frame as RasterizeGlyph(int, RasterOptions).
Returns null when the backend cannot draw this glyph's layer, and the pipeline then uses its
bitmap outline for it. The default returns null for every glyph.
RasterizedGlyph? RasterizeOutlineLayer(int codepoint, RasterOptions options, int width, OutlineShape shape, float heightScale = 1)
Parameters
codepointintThe Unicode character code.
optionsRasterOptionsThe same options the glyph itself is rendered with.
widthintOutline width in pixels: how far the layer extends past the glyph.
shapeOutlineShapeThe pen: round (Euclidean distance), square (Chebyshev) or plus (Manhattan).
heightScalefloatThe vertical stretch the pipeline applies to the glyph and this layer afterwards (HeightPercent / 100). Draw the ring
widthpixels wide andwidth/heightScalepixels tall, so that once stretched it iswidthpixels all round.
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).