Back to API Reference
Class

SpriteFont

sealed
Inherits:ColorFontCore

The process-wide colour font whose glyphs are sprites. Every inline sprite of every component is a glyph of this runtime, so it takes a glyph's place in the text mesh — the layer stack in order, world-space text, effects through its silhouette field — while drawing from its own texture at native resolution through the sub-mesh its component keeps per texture; nothing is copied into an atlas. A silhouette field is derived from a read-back of the sprite's pixels only when an effect asks for one. Glyph ids are issued per Sprite object, hold until the sprite is unregistered and are never reissued. The nominal glyph box is 1 em tall on the baseline, its width the sprite's aspect.

public static SpriteFont Instance{ get }

The singleton, created on first access. Main thread on creation.

public int FontDataHash{ get }
protected string DiagnosticNamePrefix{ get }
public override UniTextFontError LoadFontFace()
public override void ClearDynamicData()

Clears rendered data while preserving registered sprites and their glyph identities.

public override void Dispose()

Retires every registration and drops the singleton, so Instance answers with a live font again.

public override bool HasGlyphInAtlas()

A registered sprite is always drawable: its pixels are its own texture.

public uint Register()

Glyph id of a sprite, issued on first sight. The font holds the sprite and its texture until Unregister. Main thread — reads the sprite's rect, texture and mesh.

public bool Unregister()

Releases the font's hold on a sprite and its texture, retiring its glyph id for good. Text still showing the sprite drops it on its next rebuild, and a catalog that still lists it registers it again under a new id — unregister only what the catalogs no longer name. False when the font does not hold the sprite.

public override void ReadFontDefinition()
public bool TryGetGlyph()

Glyph id and width-over-height aspect of a registered sprite; false for one the font does not hold. Safe on worker threads.

protected override GlyphMetrics ComputeGlyphMetrics()

A sprite glyph is its rect's aspect wide and one em tall, standing on the baseline.