Table of Contents

Class DynamicSpriteFont

Namespace
Icy.Rendering.Fonts
Assembly
IcyUI.dll

Represents a dynamic font that can render glyphs at any size at runtime.

public class DynamicSpriteFont : SpriteFont, ISpanDrawableFont, IFont
Inheritance
DynamicSpriteFont
Implements
Inherited Members
Extension Methods

Constructors

DynamicSpriteFont(FontInfo, IGlyphRasterizer, DynamicFontAtlas, IFallbackFontResolver?)

Initializes a new instance of the DynamicSpriteFont class.

public DynamicSpriteFont(FontInfo info, IGlyphRasterizer rasterizer, DynamicFontAtlas atlas, IFallbackFontResolver? resolver = null)

Parameters

info FontInfo

Information about the font.

rasterizer IGlyphRasterizer

The glyph rasterizer to use.

atlas DynamicFontAtlas

The texture atlas to store glyphs in.

resolver IFallbackFontResolver

An instance of the service that helps with getting glyphs that are not presented in this font.

Methods

ClearCache()

Clears the glyph cache.

public void ClearCache()

GetGlyph(int)

Gets the glyph for the specified character codepoint.

public override FontGlyph GetGlyph(int codepoint)

Parameters

codepoint int

Codepoint to get glyph for.

Returns

FontGlyph

Glyph info to use with this font.

Remarks

If the requested codepoint is not found in the font, this method will attempt to return the glyph for DefaultCodepoint. If that also fails, it returns None.

GetKerning(FontGlyph, FontGlyph)

Gets the kerning between two glyphs.

protected override float GetKerning(FontGlyph current, FontGlyph previous)

Parameters

current FontGlyph

Current glyph info.

previous FontGlyph

Previous glyph info.

Returns

float

Kerning value in pixels.

Remarks

Kerning adjusts the spacing between specific pairs of glyphs to improve visual appearance. For example, in "VA", the 'A' might be moved slightly left to tuck under the 'V'.

SupportsCharacter(int)

Checks if a font supports specified codepoint instance.

public override bool SupportsCharacter(int codepoint)

Parameters

codepoint int

The Unicode codepoint for the character to use.

Returns

bool

true if this font instance can render specified character; otherwise false.

TryGetDeviceGlyph(int, float, out FontGlyph)

Tries to get a glyph rasterized for the specified device scale, so text drawn under a scaling transform stays crisp.

protected override bool TryGetDeviceGlyph(int codepoint, float deviceScale, out FontGlyph glyph)

Parameters

codepoint int

The codepoint to get the glyph for.

deviceScale float

The device scale, as returned by GetDeviceScale(in Transform2D).

glyph FontGlyph

The device-resolution glyph, with its size, bearing and texture region in device pixels.

Returns

bool

true if the font can rasterize at arbitrary sizes and produced a glyph; otherwise false. The base implementation returns false (bitmap fonts are simply scaled).

Remarks

Rasterizes at Size × deviceScale into the same shared atlas, which keys glyphs by size, so device-size glyphs are cached alongside the logical ones.