Back to API Reference
Class

UniTextFont

Serialized font definition that owns face and rendering metadata and resolves its immutable source lazily. Embedded sources stay in the asset in the Editor and WebGL; other players resolve build-generated disk-backed sources. The Core materializes only when glyph or shaping work first needs this face.

Derived Types(3)

Types that inherit from UniTextFont.

Nested Types

public Core Runtime{ get }

Lazy-built runtime that owns the FT face, glyph tables and atlas pipeline. First access after creation or source invalidation must occur on the main thread unless a provider has already captured the worker-safe slot.

protected bool HasRuntime{ get }

True if Runtime is already materialized. Avoids triggering lazy build.

public byte[] FontData{ get }

Creates a managed snapshot of the raw TTF/OTF file. This compatibility property allocates the complete file; rendering and shaping use the source backing directly.

public bool HasFontData{ get }

True when font bytes are available (either serialized or supplied by a subclass).

public int FontDataHash{ get }

Process-unique runtime identity used by atlas and shaping registries.

public FaceInfo FaceInfo{ get; set }

Font face metrics (ascender, descender, line height, etc.).

public int UnitsPerEm{ get; set }

Font design units per em (typically 1000 or 2048). Fundamental scaling unit: scale = fontSize / unitsPerEm.

public float FontScale{ get; set }

Visual scale multiplier. Compensates for fonts that render visually smaller/larger than peers at the same size (e.g. Dongle).

public bool ParticipatesInNormalization{ get; set }

Whether font-size normalization may scale this font to match the primary font. Disable to keep a decorative font's intrinsic proportions.

public float ItalicStyle{ get; set }

Synthetic italic slant in degrees, applied as a horizontal skew when an italic tag is set. 0 falls back to DefaultItalicStyle.

public int SpacingOffset{ get; set }

Baseline spacing added to every glyph's advance during shaping, in font design units. Layered additively with style-level letter-spacing.

public int SpaceAdvance{ get; set }

Space (U+0020) advance for this font, in design units; replaces the width HarfBuzz reports. SpaceAdvanceUninitialized = use the font's own / HarfBuzz fallback.

public float FakeBoldWeight{ get; set }

Baseline synthetic bold in CSS weight steps from the font's own weight (1 ≈ Regular → Bold). Renders thicker via SDF dilate and compensates advance to keep layout stable. No effect on color emoji fonts.

public int AtlasPadding{ get }

Atlas gutter in pixels around each glyph tile, prevents bilinear bleeding.

public bool IsVariable{ get }

True if this font defines OpenType variable axes.

public bool IsColor{ get }

True for color (emoji/COLR) fonts — they bypass the SDF pipeline.

public string CachedName{ get }

Cached name string usable on worker threads (Unity's name getter is main-thread-only).

public Dictionary<long,Glyph> GlyphLookupTable{ get }

(varHash48, glyphIndex) → atlas-resident Glyph. Null until the font's lookup tables are built.

protected virtual Core CreateRuntime()

Subclass hook: produce the Core, or null if bytes unavailable.

protected void InvalidateRuntime()

Tears down the current runtime; next Runtime access rebuilds.

protected void NotifyConfigurationChanged()
protected void SetRawFontDataHash()
protected void SetResolvedMetadata()

Updates coupled face metadata without exposing an observable half-updated runtime.

protected virtual Core BuildRuntime()

Subclass hook: instantiate a Core from bytes. Default uses serialized config.

public virtual byte[] CopyFontData()

Creates a managed snapshot of the complete raw font file.

public virtual int GetCachedInstanceId()

Cached Unity instance id, suitable for use as a dictionary key.

public virtual UniTextFontError LoadFontFace()

Loads the underlying FreeType face. Returns the resulting error code, or Success if already loaded.

public void ReadFontAssetDefinition()

Builds glyph and character lookup dictionaries and synthesizes invisible control characters (tab, line separators, BOM marks).

public uint GetGlyphIndexForUnicode()

Resolves a codepoint to a glyph index via HarfBuzz, with controlled fallbacks for NBSP/soft-hyphen.

public void RegisterCharacterEntries()

Adds (unicode, glyphIndex) pairs to the character table for entries discovered after the initial font load (e.g. variation selectors, emoji sequences).

public bool HasGlyphInAtlas()

Returns whether the glyph has a committed or pending entry in the selected distance-field atlas for this font's default variation.

public virtual void ClearDynamicData()

Drops the FT face, glyph caches and atlas entries owned by this font. Next access rebuilds on demand.

public void InvokeChanged()

Manually fires the Changed event. Use after editor edits that affect rendering but not atlas residency.

protected virtual void OnEnable()
protected virtual void OnDisable()
protected virtual void OnDestroy()
public static void ClearRuntimeData()

Releases native and atlas data for all live runtimes while preserving their managed font definitions, then invalidates shared resolution caches.

public static int ComputeFontDataHash()

Cheap content hash of font bytes (FNV-1a variant, sampling step on large files). Stable across runs.

protected void ResetInstanceFontDataHash()
public static UniTextFont CreateFontAsset()

Builds a runtime UniTextFont from font file bytes. FT face is loaded once to populate FaceInfo and units-per-em.

public static T CreateFontAsset()

Builds a font asset of the given UniTextFont subtype from font file bytes, populating its source, hash, units-per-em and face metrics identically to CreateFontAsset.

protected int fontDataHash
public static const float DefaultItalicStyle

Synthetic-italic slant used when a font stores none (value 0), notably OS system-font fallbacks built at runtime. The italic modifier reads it as a horizontal shear factor.