Back to API Reference
Class

UniTextFontProvider

sealed
Implements:IDisposable

Owns Unicode-sequence 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 covering runtime and exact variation instance when available, and otherwise returns the primary runtime as the intentional.notdef endpoint. Asset-backed faces are captured as worker-safe lazy slots; bare runtime companions and the emoji singleton flow through the same resolution path. The owner must dispose the provider after all processing and raster work finishes.

public static int InactiveVariationCapacity{ get; set }

Maximum number of exact variation registrations retained after their last provider releases them. Active registrations are never evicted.

public static FontVariationMemoryStats VariationMemoryStats{ get }

Returns a consistent snapshot of exact variation registrations and their ownership.

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 }

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). Derived from the runtime alone, so every id addressing one runtime — base or variation instance — yields the same multiplier. 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 runtime from a font id issued by this provider. Returns 1 for an id it never issued.

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()

Process-lifetime font identity. The primary system emoji face uses FontId; null uses 0.

public static int GetFontId()

Process-lifetime font identity from a UniTextFont asset.

public void RegisterFont()

Registers a runtime under its process identity. Writes are serialized; reads stay lock-free.

public void Dispose()

Releases all SystemFont source leases and variation registrations owned by this provider. Call only after its processing and raster work has finished.

public Core GetFont()

Resolves a font id to its registered runtime, or null when the id has no owner in this provider.

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 static void TrimUnusedVariations()

Releases every exact variation registration not leased by a live provider. Active shaping and raster data is preserved.

public ushort GetFamilyIndex()

Family index for a font id, or MaxValue when the runtime has no family owner.

public byte[] GetFontData()

Creates a managed snapshot of the complete font file for a font id, allocating and copying its full source, or returns null when unavailable.