docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TMP_FontAsset

    Inheritance
    object
    Object
    ScriptableObject
    TMP_Asset
    TMP_FontAsset
    Inherited Members
    TMP_Asset.version
    TMP_Asset.instanceID
    TMP_Asset.entityId
    TMP_Asset.hashCode
    TMP_Asset.faceInfo
    TMP_Asset.material
    TMP_Asset.materialHashCode
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetEntityId()
    Object.MemberwiseClone()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectsByType(Type)
    Object.FindObjectsByType(Type, FindObjectsInactive)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsByType<T>()
    Object.FindObjectsByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: TMPro
    Assembly: Unity.TextMeshPro.dll
    Syntax
    [Serializable]
    [ExcludeFromPreset]
    public class TMP_FontAsset : TMP_Asset

    Fields

    atlas

    The primary atlas texture containing the glyphs for this font asset.

    Declaration
    [SerializeField]
    public Texture2D atlas
    Field Value
    Type Description
    Texture2D

    boldSpacing

    The spacing between characters when using regular style.

    Declaration
    public float boldSpacing
    Field Value
    Type Description
    float

    boldStyle

    Defines the dilation of the text when using bold style.

    Declaration
    public float boldStyle
    Field Value
    Type Description
    float

    italicStyle

    Defines the slant of the text when using italic style.

    Declaration
    public byte italicStyle
    Field Value
    Type Description
    byte

    normalSpacingOffset

    The spacing between characters when using regular style.

    Declaration
    public float normalSpacingOffset
    Field Value
    Type Description
    float

    normalStyle

    Defines the dilation of the text when using regular style.

    Declaration
    public float normalStyle
    Field Value
    Type Description
    float

    tabSize

    The character width used for tab spacing.

    Declaration
    public byte tabSize
    Field Value
    Type Description
    byte

    Properties

    atlasHeight

    The height of the atlas texture(s) used by this font asset.

    Declaration
    public int atlasHeight { get; }
    Property Value
    Type Description
    int

    atlasPadding

    The padding used between glyphs contained in the atlas texture(s) used by this font asset.

    Declaration
    public int atlasPadding { get; }
    Property Value
    Type Description
    int

    atlasPopulationMode

    Declaration
    public AtlasPopulationMode atlasPopulationMode { get; set; }
    Property Value
    Type Description
    AtlasPopulationMode

    atlasRenderMode

    Declaration
    public GlyphRenderMode atlasRenderMode { get; }
    Property Value
    Type Description
    GlyphRenderMode

    atlasTexture

    The font atlas used by this font asset. This is always the texture at index [0] of the fontAtlasTextures.

    Declaration
    public Texture2D atlasTexture { get; }
    Property Value
    Type Description
    Texture2D

    atlasTextureCount

    Number of atlas textures used by this font asset.

    Declaration
    public int atlasTextureCount { get; }
    Property Value
    Type Description
    int

    atlasTextures

    Array of atlas textures that contain the glyphs used by this font asset.

    Declaration
    public Texture2D[] atlasTextures { get; set; }
    Property Value
    Type Description
    Texture2D[]

    atlasWidth

    The width of the atlas texture(s) used by this font asset.

    Declaration
    public int atlasWidth { get; }
    Property Value
    Type Description
    int

    characterLookupTable

    Dictionary used to lookup characters contained in the font asset by their unicode values.

    Declaration
    public Dictionary<uint, TMP_Character> characterLookupTable { get; }
    Property Value
    Type Description
    Dictionary<uint, TMP_Character>

    characterTable

    List containing the characters of the given font asset.

    Declaration
    public List<TMP_Character> characterTable { get; }
    Property Value
    Type Description
    List<TMP_Character>

    creationSettings

    The settings used in the Font Asset Creator when this font asset was created or edited.

    Declaration
    public FontAssetCreationSettings creationSettings { get; set; }
    Property Value
    Type Description
    FontAssetCreationSettings

    fallbackFontAssetTable

    List containing the Fallback font assets for this font.

    Declaration
    public List<TMP_FontAsset> fallbackFontAssetTable { get; set; }
    Property Value
    Type Description
    List<TMP_FontAsset>

    fontFeatureTable

    Table containing the various font features of this font asset.

    Declaration
    public TMP_FontFeatureTable fontFeatureTable { get; }
    Property Value
    Type Description
    TMP_FontFeatureTable

    fontInfo

    The general information about the font. This property and FaceInfo_Legacy type are no longer used in version 1.1.0 of the font asset.

    Declaration
    [Obsolete("The fontInfo property and underlying type is now obsolete. Please use the faceInfo property and FaceInfo type instead.")]
    public FaceInfo_Legacy fontInfo { get; }
    Property Value
    Type Description
    FaceInfo_Legacy

    fontWeightTable

    Array containing font assets to be used as alternative typefaces for the various potential font weights of this font asset.

    Declaration
    public TMP_FontWeightPair[] fontWeightTable { get; }
    Property Value
    Type Description
    TMP_FontWeightPair[]

    getFontFeatures

    Determines if OpenType font features should be retrieved from the source font file as new characters and glyphs are added dynamically to the font asset.

    Declaration
    public bool getFontFeatures { get; set; }
    Property Value
    Type Description
    bool

    glyphLookupTable

    Dictionary used to lookup glyphs contained in the font asset by their index.

    Declaration
    public Dictionary<uint, Glyph> glyphLookupTable { get; }
    Property Value
    Type Description
    Dictionary<uint, Glyph>

    glyphTable

    List of glyphs contained in the font asset.

    Declaration
    public List<Glyph> glyphTable { get; }
    Property Value
    Type Description
    List<Glyph>

    isMultiAtlasTexturesEnabled

    Enables the font asset to create additional atlas textures as needed.

    Declaration
    public bool isMultiAtlasTexturesEnabled { get; set; }
    Property Value
    Type Description
    bool

    sourceFontFile

    Source font file when atlas population mode is set to dynamic. Null when the atlas population mode is set to static.

    Declaration
    public Font sourceFontFile { get; }
    Property Value
    Type Description
    Font

    Methods

    ClearFontAssetData(bool)

    Clears font asset data including the glyph and character tables and textures. Function might be changed to Internal and only used in tests.

    Declaration
    public void ClearFontAssetData(bool setAtlasSizeToZero = false)
    Parameters
    Type Name Description
    bool setAtlasSizeToZero

    Will set the atlas texture size to zero width and height if true.

    CreateFontAsset(string, int, int, int, GlyphRenderMode, int, int)

    Creates a new font asset instance from the font file at the given file path.

    Declaration
    public static TMP_FontAsset CreateFontAsset(string fontFilePath, int faceIndex, int samplingPointSize, int atlasPadding, GlyphRenderMode renderMode, int atlasWidth, int atlasHeight)
    Parameters
    Type Name Description
    string fontFilePath

    The file path of the font file.

    int faceIndex

    The index of font face.

    int samplingPointSize

    The sampling point size.

    int atlasPadding

    The padding between individual glyphs in the font atlas texture.

    GlyphRenderMode renderMode

    The atlas render mode.

    int atlasWidth

    The atlas texture width.

    int atlasHeight

    The atlas texture height.

    Returns
    Type Description
    TMP_FontAsset

    An instance of the newly created font asset.

    CreateFontAsset(string, string, int)

    Creates a new font asset instance from the given family name and style.

    Declaration
    public static TMP_FontAsset CreateFontAsset(string familyName, string styleName, int pointSize = 90)
    Parameters
    Type Name Description
    string familyName

    The family name of the source font.

    string styleName

    The style name of the source font face.

    int pointSize

    Optional point size.

    Returns
    Type Description
    TMP_FontAsset

    An instance of the newly created font asset.

    CreateFontAsset(Font)

    Creates a new font asset instance from the provided font object.

    Declaration
    public static TMP_FontAsset CreateFontAsset(Font font)
    Parameters
    Type Name Description
    Font font

    The source font object.

    Returns
    Type Description
    TMP_FontAsset

    An instance of the newly created font asset.

    CreateFontAsset(Font, int, int, GlyphRenderMode, int, int, AtlasPopulationMode, bool)

    Creates a new font asset instance from the provided font object.

    Declaration
    public static TMP_FontAsset CreateFontAsset(Font font, int samplingPointSize, int atlasPadding, GlyphRenderMode renderMode, int atlasWidth, int atlasHeight, AtlasPopulationMode atlasPopulationMode = AtlasPopulationMode.Dynamic, bool enableMultiAtlasSupport = true)
    Parameters
    Type Name Description
    Font font

    The source font object.

    int samplingPointSize

    The sampling point size.

    int atlasPadding

    The padding between individual glyphs in the font atlas texture.

    GlyphRenderMode renderMode

    The atlas render mode.

    int atlasWidth

    The atlas texture width.

    int atlasHeight

    The atlas texture height.

    AtlasPopulationMode atlasPopulationMode

    The atlas population mode.

    bool enableMultiAtlasSupport

    Enable multi atlas texture.

    Returns
    Type Description
    TMP_FontAsset

    An instance of the newly created font asset.

    GetCharacters(TMP_FontAsset)

    Extracts all characters from the font asset as a string.

    Declaration
    public static string GetCharacters(TMP_FontAsset fontAsset)
    Parameters
    Type Name Description
    TMP_FontAsset fontAsset

    The font asset to extract characters from.

    Returns
    Type Description
    string

    A string containing all characters defined in the font asset.

    GetCharactersArray(TMP_FontAsset)

    Returns an array of all character Unicode values from the font asset.

    Declaration
    public static int[] GetCharactersArray(TMP_FontAsset fontAsset)
    Parameters
    Type Name Description
    TMP_FontAsset fontAsset

    The font asset to extract character Unicode values from.

    Returns
    Type Description
    int[]

    An array of Unicode values for all characters defined in the font asset.

    HasCharacter(char, bool, bool)

    Checks whether a character is contained in the font asset, with the option to also check potential local fallbacks.

    Declaration
    public bool HasCharacter(char character, bool searchFallbacks = false, bool tryAddCharacter = false)
    Parameters
    Type Name Description
    char character

    The character to check.

    bool searchFallbacks

    Whether to search fallback font assets.

    bool tryAddCharacter

    If true and the font is dynamic, attempt to add the character to the font asset.

    Returns
    Type Description
    bool

    True if the character exists in the font asset or fallbacks.

    HasCharacter(int)

    Checks whether a specific character exists in the font asset.

    Declaration
    public bool HasCharacter(int character)
    Parameters
    Type Name Description
    int character

    Unicode value of the character to check.

    Returns
    Type Description
    bool

    True if the character exists in the font asset.

    HasCharacters(string)

    Checks whether specific characters exist in the font asset.

    Declaration
    public bool HasCharacters(string text)
    Parameters
    Type Name Description
    string text

    String containing the characters to check.

    Returns
    Type Description
    bool

    True if all characters exist in the font asset; otherwise false.

    HasCharacters(string, out List<char>)

    Checks whether the given characters exist in the font asset and returns a list of any missing characters.

    Declaration
    public bool HasCharacters(string text, out List<char> missingCharacters)
    Parameters
    Type Name Description
    string text

    String containing the characters to check.

    List<char> missingCharacters

    List of missing characters.

    Returns
    Type Description
    bool

    True if all characters exist in the font asset; otherwise false.

    HasCharacters(string, out uint[], bool, bool)

    Checks whether the characters in the given string are contained in the font asset, with the option to also check local fallbacks.

    Declaration
    public bool HasCharacters(string text, out uint[] missingCharacters, bool searchFallbacks = false, bool tryAddCharacter = false)
    Parameters
    Type Name Description
    string text

    String containing the characters to check.

    uint[] missingCharacters

    Array containing the unicode values of the missing characters.

    bool searchFallbacks

    Determines if fallback font assets assigned to this font asset should be searched.

    bool tryAddCharacter

    If true and the font is dynamic, attempt to add missing characters to the font asset.

    Returns
    Type Description
    bool

    Returns true if all requested characters are available in the font asset and potential fallbacks.

    ReadFontAssetDefinition()

    Reads the various data tables of the font asset and populates various data structures to allow for faster lookup of related font asset data.

    Declaration
    public void ReadFontAssetDefinition()

    TryAddCharacters(string, bool)

    Try adding the characters from the provided string to the font asset.

    Declaration
    public bool TryAddCharacters(string characters, bool includeFontFeatures = false)
    Parameters
    Type Name Description
    string characters

    String containing the characters to add to the font asset.

    bool includeFontFeatures

    Whether to include font features when adding characters.

    Returns
    Type Description
    bool

    Returns true if all the characters were successfully added to the font asset. Return false otherwise.

    TryAddCharacters(string, out string, bool)

    Try adding the characters from the provided string to the font asset.

    Declaration
    public bool TryAddCharacters(string characters, out string missingCharacters, bool includeFontFeatures = false)
    Parameters
    Type Name Description
    string characters

    String containing the characters to add to the font asset.

    string missingCharacters

    String containing the characters that could not be added to the font asset.

    bool includeFontFeatures

    Whether to include font features when adding characters.

    Returns
    Type Description
    bool

    Returns true if all the characters were successfully added to the font asset. Return false otherwise.

    TryAddCharacters(uint[], bool)

    Try adding the characters from the provided string to the font asset.

    Declaration
    public bool TryAddCharacters(uint[] unicodes, bool includeFontFeatures = false)
    Parameters
    Type Name Description
    uint[] unicodes

    Array that contains the Unicode values of the characters to add to the font asset.

    bool includeFontFeatures

    Whether to include font features when adding characters.

    Returns
    Type Description
    bool

    Returns true if all the characters were successfully added to the font asset. Return false otherwise.

    TryAddCharacters(uint[], out uint[], bool)

    Try adding the characters from the provided string to the font asset.

    Declaration
    public bool TryAddCharacters(uint[] unicodes, out uint[] missingUnicodes, bool includeFontFeatures = false)
    Parameters
    Type Name Description
    uint[] unicodes

    Array that contains the Unicode values of the characters to add to the font asset.

    uint[] missingUnicodes

    Array containing the Unicode values of characters that could not be added to the font asset.

    bool includeFontFeatures

    Whether to include font features when adding characters.

    Returns
    Type Description
    bool

    Returns true if all the characters were successfully added to the font asset. Return false otherwise.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)