Table of Contents

Class DynamicFontAtlas

Namespace
Icy.Rendering.Fonts
Assembly
IcyUI.dll

Represents a dynamic texture atlas for storing font glyphs.

public class DynamicFontAtlas : IFontAtlas
Inheritance
DynamicFontAtlas
Implements
Inherited Members
Extension Methods

Constructors

DynamicFontAtlas(IRenderContext, uint)

Initializes a new instance of the DynamicFontAtlas class.

public DynamicFontAtlas(IRenderContext context, uint maxPages = 4)

Parameters

context IRenderContext

An instance of the IRenderContext to create textures from.

maxPages uint

The maximum number of texture pages to create.

Properties

Glyphs

Gets all glyphs stored in the atlas.

public IReadOnlyDictionary<StyledGlyphDefinition, FontGlyph> Glyphs { get; }

Property Value

IReadOnlyDictionary<StyledGlyphDefinition, FontGlyph>

PageCount

Gets the number of texture pages.

public int PageCount { get; }

Property Value

int

Textures

Gets the font textures.

public IReadOnlyCollection<ITexture> Textures { get; }

Property Value

IReadOnlyCollection<ITexture>

Methods

AddEmptyGlyph(FontGlyph, FontInfo)

Adds an empty glyph for rendering purposes.

public void AddEmptyGlyph(FontGlyph glyph, FontInfo fontInfo)

Parameters

glyph FontGlyph

An instance of the FontGlyph to add to a font.

fontInfo FontInfo

Info about the font to store font-specific glyph info for.

Remarks

This method can be used for non-rendered glyphs that represent some unique spacings or kernings. The most common example of an "empty" glyph is a whitespace. These glyphs are not saved to the atlas so they don't affect textures. However, they're used in calculations.

Clear()

Clears all atlas data by removing all the pages and glyphs data.

public void Clear()

GetGlyph(StyledGlyphDefinition)

Gets the glyph for a codepoint.

public FontGlyph? GetGlyph(StyledGlyphDefinition codepoint)

Parameters

codepoint StyledGlyphDefinition

Returns

FontGlyph?

The glyph if it exists; otherwise, null.

GetGlyphPage(in FontGlyph)

Gets a page for the glyph with the specified codepoint.

public ITexture GetGlyphPage(in FontGlyph glyph)

Parameters

glyph FontGlyph

Glyph to get atlas page for.

Returns

ITexture

A texture page for the specified glyph.

TryAddGlyph(FontGlyph, Memory<byte>, FontInfo)

Tries to add a glyph to this atlas instance.

public FontGlyph TryAddGlyph(FontGlyph glyph, Memory<byte> pixels, FontInfo fontInfo)

Parameters

glyph FontGlyph

A glyph to add to the atlas.

pixels Memory<byte>

Pixels buffer to add to the texture.

fontInfo FontInfo

Info about the font that adds a glyph.

Returns

FontGlyph

Modified glyph instance with page index and texture region set.