Docsv2.12.12
Back to API Reference
Class

UniTextFontProvider

sealed

Owns codepoint→font resolution for a text object: composes the family chain from the assigned font and font stack, walks it (plus emoji and the always-on SystemFont fallback) to pick a runtime per codepoint, and stores Core instances so worker-thread companions and the emoji singleton (both plain Core, no Unity asset) flow through the same code path.

public float FontSize{ get; set }

Current font size in points. Setter recomputes the cached font scale.

public Core PrimaryFont{ get }

Resolved primary font runtime. Provides strut metrics and serves as the head of codepoint resolution.

public int PrimaryFontId{ get }

Stable id of PrimaryFont.

public bool HasFaces{ get; set }

True if the resolved family chain carries variant faces (Bold/Italic) or a variable font.

public void SetFontSize()

Equivalent to setting FontSize.

[ctor]public UniTextFontProvider()

Initializes the provider. The resolution chain is primary (if set), then fontStack's families, then Default (the configured SystemFont or the OS default) as the always-on final fallback. With nothing assigned, Default becomes the primary. Main-thread only.

public float GetNormalizationScale()

Per-font multiplier matching a fallback/secondary font to the primary font's reference metric (CSS font-size-adjust). Returns 1 when normalization is off, the font is the primary, the font opts out, or a metric is unavailable.

public float GetNormalizationScale()

Convenience overload resolving the font id from a runtime instance.

public float MetricScale()

Design-units → pixels for fontId at fontSize: folds in the font's FontScale and the active normalization (CSS font-size-adjust). Multiply any design-unit metric (advance, bearing, line height) by the result. Returns 0 when the font is unavailable.

public float MetricScale()
public void SetNormalization()

Sets the active normalization metric and target, recomputing the primary reference ratio. Called by a font-size-match modifier so the provider stays modifier-agnostic.

public static int GetFontId()

Stable font identifier. Equals FontId for emoji, FontDataHash otherwise. Returns 0 for null.

public static int GetFontId()

Stable font identifier from a UniTextFont asset.

public void RegisterFontAsset()

Registers a font runtime under fontId so subsequent GetFontAsset lookups resolve to it. Required for fallback fonts discovered at runtime. FontId is ignored — emoji resolves through its own lookup branch and the id is unstorable in the registry.

public Core GetFontAsset()

Resolves a font id to its registered runtime. Falls back to PrimaryFont if unknown.

public void GetLineMetrics()

Strut metrics from the primary font, scaled to size points. descender is negative; lineHeight falls back to 1.2 × extent when the font omits it.

public float GetCapHeight()

Cap height (top of capital letters) of the primary font, scaled to size points. Returns 0 when unavailable.

public float GetXHeight()

x-height (top of lowercase letters) of the primary font, scaled to size points. Returns 0 when unavailable.

public void GetTypoMetrics()

Typographic ascent/descent (OS/2 sTypo) of the primary font, scaled to size points — the designer's tight content box. Falls back to the selected ascent/descent line when the font omits typo metrics. descent is negative.

public int TryGetFontIdByFamilyName()

Resolves a name to its primary font id, registering the runtime with this provider if needed. Returns 0 when the name is empty or unknown. Case-sensitive, first-wins across the family chain.

public int FindFontForCodepoint()

Finds the best font id to render codepoint via the fallback chain; result is cached in SharedFontCache.

public int FindFontForCodepoint()

Same as FindFontForCodepoint but prefers families whose preferredLanguage matches the given language registry index.

public ushort GetFamilyIndex()

Family index for a font id (used for face-matching lookups). Returns 0 if not found.

public byte[] GetFontData()

Raw font file bytes for a font id, or null if not available.