Back to API Reference
Class

UniTextFontProvider

sealed

Manages font assets and provides font lookup services for text rendering.

Remarks

The font provider handles: Primary font and fallback font resolution Font scaling based on requested font size Glyph caching in texture atlases Font data access (glyph lookup, font data bytes) Font family lookup for variant/variable font resolution Uses SharedFontCache for fast codepoint-to-font mapping.
public float FontSize{ get; set }

Gets or sets the current font size in points.

public UniTextFont PrimaryFont{ get }

Gets the main (primary) font asset.

public int PrinaryFontId{ get }

Gets the unique identifier for the primary font.

public bool HasFaces{ get; set }

Whether any family in the resolved chain has faces (variants or variable fonts).

public void SetFontSize(float size)

Sets the font size in points.

[ctor]public UniTextFontProvider(UniTextFontStack fontStack, float fontSize)

Initializes the font provider with the specified fonts.

public static int GetFontId(UniTextFont font)

Gets the unique font identifier for a font asset.

public void RegisterFontAsset(int fontId, UniTextFont font)

Registers a font asset with the provider.

public UniTextFont GetFontAsset(int fontId)

Gets a font asset by its identifier.

public void GetLineMetrics(float size, float ascender, float descender, float lineHeight)

Gets line metrics scaled to the specified font size.

public float GetCapHeight(float size)

Gets the cap height (top of capital letters) scaled to the specified font size.

public int TryGetFontIdByFamilyName()

Resolves a name to its primary font's fontId, registering the font with this provider if needed. Returns 0 when the name is empty or unknown.

public int FindFontForCodepoint(int codepoint)

Finds the best font to render a codepoint, using fallback chain if needed.

public int FindFontForCodepoint(int codepoint, byte language)

Finds the best font to render a codepoint given a language tag registry index. Prefers families whose preferredLanguage matches the tag.

public ushort GetFamilyIndex()

Gets the family index for a font ID. Returns 0 (first family) if not found.

public byte[] GetFontData(int fontId)

Gets the raw font data (TTF/OTF bytes) for a font.

See Also