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 and stay stable for the process. 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 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. Main thread — reads the sprite's rect, texture and mesh.

public bool TryGetGlyph()

Glyph id and width-over-height aspect of a registered sprite; false for one never registered. 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.