Back to API Reference
Class

UniTextFont

Font asset containing glyph data, metrics, and texture atlases for text rendering.

Remarks

UniTextFont is a ScriptableObject that stores: Font file data (TTF/OTF bytes) for FreeType rendering Face information (metrics, ascender, descender) Glyph table with metrics for text layout Glyph curve cache for SDF rendering Glyph curves are extracted at runtime when first needed and stored in a shared curve atlas.

Nested Types

public bool IsVariable{ get }

True if this font has any variable font axes.

public string CachedName{ get; set }
public byte[] FontData{ get }

Gets the raw font file data (TTF/OTF bytes). Decompresses from Zstd on first access.

public float ItalicStyle{ get }

Gets the italic slant angle in degrees.

public int FontDataHash{ get }

Gets the hash of the font data for identification.

public bool HasFontData{ get }

Returns true if font file data is available.

public FaceInfo FaceInfo{ get; set }

Gets or sets the font face information (metrics, ascender, descender, etc.).

public int UnitsPerEm{ get; set }

Gets or sets the font design units per em (typically 1000 or 2048).

public float FontScale{ get; set }

Visual scale multiplier for this font asset.

public int AtlasPadding{ get }

Gets the padding between glyphs in the atlas (EmojiFont only).

public Dictionary<long,Glyph> GlyphLookupTable{ get }

Gets the glyph lookup table (glyph key → Glyph).

public bool IsColor{ get }
public virtual int GetCachedInstanceId()

Gets the cached Unity instance ID, initializing on first access.

public static int ComputeFontDataHash(byte[] data)

Computes a hash of font file data for identification.

public void ReadFontAssetDefinition()

Initializes lookup dictionaries from serialized glyph and character tables.

protected IntPtr EnsureFTFace()
protected void ReleaseFTFace()
public virtual UniTextFontError LoadFontFace()

Loads the font face for glyph operations.

public uint GetGlyphIndexForUnicode(uint unicode)

Gets the glyph index for a Unicode codepoint.

public void RegisterCharacterEntries(List<ValueTuple<uint,uint>> entries)

Registers character-to-glyph mappings for later lookup.

protected List<uint> FilterNewGlyphs()

Filters glyph indices, removing zeros and already-known glyphs. Returns a reusable list of unique indices to add, or null if nothing to add.

public bool HasGlyphInAtlas()

Checks if a glyph is already cached (curve data extracted or bitmap rendered).

public virtual long EstimateTileArea()
public static UniTextFont CreateFontAsset(byte[] fontBytes)

Creates a new font asset from raw font file bytes.

public virtual void ClearDynamicData()

Clears all dynamically generated glyph data and resets atlas textures.

public void InvokeChanged()
public static void ClearRuntimeData()

Clears dynamic data for all loaded font assets and invalidates shared caches.

protected byte[] fontData
protected int fontDataHash
protected List<uint> glyphIndexList
protected List<long> batchProtectedKeys

See Also