Class TMP_FontAsset
Inheritance
System.Object
UnityEngine.Object
UnityEngine.ScriptableObject
TMP_FontAsset
Inherited Members
UnityEngine.ScriptableObject.SetDirty()
UnityEngine.ScriptableObject.CreateInstance(System.String)
UnityEngine.ScriptableObject.CreateInstance(System.Type)
UnityEngine.ScriptableObject.CreateInstance<T>()
UnityEngine.Object.GetInstanceID()
UnityEngine.Object.GetHashCode()
UnityEngine.Object.Equals(System.Object)
UnityEngine.Object.InstantiateAsync<T>(T)
UnityEngine.Object.InstantiateAsync<T>(T, UnityEngine.Transform)
UnityEngine.Object.InstantiateAsync<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.InstantiateAsync<T>(T, UnityEngine.Transform, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Transform)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, System.ReadOnlySpan<UnityEngine.Vector3>, System.ReadOnlySpan<UnityEngine.Quaternion>)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Transform, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Transform, UnityEngine.Vector3, UnityEngine.Quaternion, System.Threading.CancellationToken)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Transform, System.ReadOnlySpan<UnityEngine.Vector3>, System.ReadOnlySpan<UnityEngine.Quaternion>)
UnityEngine.Object.InstantiateAsync<T>(T, System.Int32, UnityEngine.Transform, System.ReadOnlySpan<UnityEngine.Vector3>, System.ReadOnlySpan<UnityEngine.Quaternion>, System.Threading.CancellationToken)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Transform)
UnityEngine.Object.Instantiate(UnityEngine.Object)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.SceneManagement.Scene)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Transform)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Transform, System.Boolean)
UnityEngine.Object.Instantiate<T>(T)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform, System.Boolean)
UnityEngine.Object.Destroy(UnityEngine.Object, System.Single)
UnityEngine.Object.Destroy(UnityEngine.Object)
UnityEngine.Object.DestroyImmediate(UnityEngine.Object, System.Boolean)
UnityEngine.Object.DestroyImmediate(UnityEngine.Object)
UnityEngine.Object.FindObjectsOfType(System.Type)
UnityEngine.Object.FindObjectsOfType(System.Type, System.Boolean)
UnityEngine.Object.FindObjectsByType(System.Type, UnityEngine.FindObjectsSortMode)
UnityEngine.Object.FindObjectsByType(System.Type, UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
UnityEngine.Object.DontDestroyOnLoad(UnityEngine.Object)
UnityEngine.Object.DestroyObject(UnityEngine.Object, System.Single)
UnityEngine.Object.DestroyObject(UnityEngine.Object)
UnityEngine.Object.FindSceneObjectsOfType(System.Type)
UnityEngine.Object.FindObjectsOfTypeIncludingAssets(System.Type)
UnityEngine.Object.FindObjectsOfType<T>()
UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
UnityEngine.Object.FindObjectOfType<T>()
UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
UnityEngine.Object.FindFirstObjectByType<T>()
UnityEngine.Object.FindAnyObjectByType<T>()
UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
UnityEngine.Object.FindObjectsOfTypeAll(System.Type)
UnityEngine.Object.FindObjectOfType(System.Type)
UnityEngine.Object.FindFirstObjectByType(System.Type)
UnityEngine.Object.FindAnyObjectByType(System.Type)
UnityEngine.Object.FindObjectOfType(System.Type, System.Boolean)
UnityEngine.Object.FindFirstObjectByType(System.Type, UnityEngine.FindObjectsInactive)
UnityEngine.Object.FindAnyObjectByType(System.Type, UnityEngine.FindObjectsInactive)
UnityEngine.Object.ToString()
UnityEngine.Object.name
UnityEngine.Object.hideFlags
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: TMPro
Syntax
[Serializable]
public class TMP_FontAsset : TMP_Asset
Fields
atlas
Declaration
[SerializeField]
public Texture2D atlas
Field Value
Type |
Description |
UnityEngine.Texture2D |
|
boldSpacing
The spacing between characters when using regular style.
Declaration
Field Value
Type |
Description |
System.Single |
|
boldStyle
Defines the dilation of the text when using bold style.
Declaration
Field Value
Type |
Description |
System.Single |
|
italicStyle
Defines the slant of the text when using italic style.
Declaration
Field Value
Type |
Description |
System.Byte |
|
m_FallbackFontAssetTable
Declaration
[SerializeField]
public List<TMP_FontAsset> m_FallbackFontAssetTable
Field Value
normalSpacingOffset
The spacing between characters when using regular style.
Declaration
public float normalSpacingOffset
Field Value
Type |
Description |
System.Single |
|
normalStyle
Defines the dilation of the text when using regular style.
Declaration
Field Value
Type |
Description |
System.Single |
|
tabSize
Declaration
Field Value
Type |
Description |
System.Byte |
|
Properties
atlasHeight
The height of the atlas texture(s) used by this font asset.
Declaration
public int atlasHeight { get; }
Property Value
Type |
Description |
System.Int32 |
|
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 |
System.Int32 |
|
atlasPopulationMode
Declaration
public AtlasPopulationMode atlasPopulationMode { get; set; }
Property Value
atlasRenderMode
Declaration
public GlyphRenderMode atlasRenderMode { get; }
Property Value
Type |
Description |
UnityEngine.TextCore.LowLevel.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 |
UnityEngine.Texture2D |
|
atlasTextures
Array of atlas textures that contain the glyphs used by this font asset.
Declaration
public Texture2D[] atlasTextures { get; set; }
Property Value
Type |
Description |
UnityEngine.Texture2D[] |
|
atlasWidth
The width of the atlas texture(s) used by this font asset.
Declaration
public int atlasWidth { get; }
Property Value
Type |
Description |
System.Int32 |
|
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 |
System.Collections.Generic.Dictionary<System.UInt32, TMP_Character> |
|
characterTable
List containing the characters of the given font asset.
Declaration
public List<TMP_Character> characterTable { get; }
Property Value
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
faceInfo
Information about the font face.
Declaration
public FaceInfo faceInfo { get; }
Property Value
Type |
Description |
UnityEngine.TextCore.FaceInfo |
|
fallbackFontAssetTable
List containing the Fallback font assets for this font.
Declaration
public List<TMP_FontAsset> fallbackFontAssetTable { get; set; }
Property Value
fontFeatureTable
Table containing the various font features of this font asset.
Declaration
public TMP_FontFeatureTable fontFeatureTable { get; }
Property Value
fontInfo
The general information about the font.
This property and FaceInfo_Legacy type are not 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
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
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 |
System.Collections.Generic.Dictionary<System.UInt32, UnityEngine.TextCore.Glyph> |
|
glyphTable
List of glyphs contained in the font asset.
Declaration
public List<Glyph> glyphTable { get; }
Property Value
Type |
Description |
System.Collections.Generic.List<UnityEngine.TextCore.Glyph> |
|
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 |
UnityEngine.Font |
|
version
The version of the font asset class.
Version 1.1.0 adds support for the new TextCore.FontEngine and Dynamic SDF system.
Declaration
public string version { get; }
Property Value
Type |
Description |
System.String |
|
Methods
ClearFontAssetData(Boolean)
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 |
System.Boolean |
setAtlasSizeToZero |
Will set the atlas texture size to zero width and height if true.
|
CreateFontAsset(Font)
Create new instance of a font asset using default settings.
Declaration
public static TMP_FontAsset CreateFontAsset(Font font)
Parameters
Type |
Name |
Description |
UnityEngine.Font |
font |
|
Returns
CreateFontAsset(Font, Int32, Int32, GlyphRenderMode, Int32, Int32, AtlasPopulationMode)
Create new instance of a font asset.
Declaration
public static TMP_FontAsset CreateFontAsset(Font font, int samplingPointSize, int atlasPadding, GlyphRenderMode renderMode, int atlasWidth, int atlasHeight, AtlasPopulationMode atlasPopulationMode = AtlasPopulationMode.Dynamic)
Parameters
Type |
Name |
Description |
UnityEngine.Font |
font |
The source font file.
|
System.Int32 |
samplingPointSize |
The sampling point size.
|
System.Int32 |
atlasPadding |
The padding / spread between individual glyphs in the font asset.
|
UnityEngine.TextCore.LowLevel.GlyphRenderMode |
renderMode |
|
System.Int32 |
atlasWidth |
The atlas texture width.
|
System.Int32 |
atlasHeight |
The atlas texture height.
|
AtlasPopulationMode |
atlasPopulationMode |
|
Returns
GetCharacters(TMP_FontAsset)
Function to extract all the characters from a font asset.
Declaration
public static string GetCharacters(TMP_FontAsset fontAsset)
Parameters
Returns
Type |
Description |
System.String |
|
GetCharactersArray(TMP_FontAsset)
Function which returns an array that contains all the characters from a font asset.
Declaration
public static int[] GetCharactersArray(TMP_FontAsset fontAsset)
Parameters
Returns
Type |
Description |
System.Int32[] |
|
HasCharacter(Char)
Function to check if a certain character exists in the font asset.
Declaration
public bool HasCharacter(char character)
Parameters
Type |
Name |
Description |
System.Char |
character |
|
Returns
Type |
Description |
System.Boolean |
|
HasCharacter(Char, Boolean)
Function to check if a character is contained in the font asset with the option to also check through fallback font assets.
Declaration
public bool HasCharacter(char character, bool searchFallbacks)
Parameters
Type |
Name |
Description |
System.Char |
character |
|
System.Boolean |
searchFallbacks |
|
Returns
Type |
Description |
System.Boolean |
|
HasCharacter(Int32)
Function to check if a certain character exists in the font asset.
Declaration
public bool HasCharacter(int character)
Parameters
Type |
Name |
Description |
System.Int32 |
character |
|
Returns
Type |
Description |
System.Boolean |
|
HasCharacters(String)
Function to check if certain characters exists in the font asset. Function returns false if any characters are missing.
Declaration
public bool HasCharacters(string text)
Parameters
Type |
Name |
Description |
System.String |
text |
String containing the characters to check
|
Returns
Type |
Description |
System.Boolean |
|
HasCharacters(String, out List<Char>)
Function to check if certain characters exists in the font asset. Function returns a list of missing characters.
Declaration
public bool HasCharacters(string text, out List<char> missingCharacters)
Parameters
Type |
Name |
Description |
System.String |
text |
|
System.Collections.Generic.List<System.Char> |
missingCharacters |
|
Returns
Type |
Description |
System.Boolean |
|
ReadFontAssetDefinition()
Declaration
public void ReadFontAssetDefinition()
TryAddCharacters(String)
Try adding the characters from the provided string to the font asset.
Declaration
public bool TryAddCharacters(string characters)
Parameters
Type |
Name |
Description |
System.String |
characters |
String containing the characters to add to the font asset.
|
Returns
Type |
Description |
System.Boolean |
Returns true if all the characters were successfully added to the font asset. Return false otherwise.
|
TryAddCharacters(String, out String)
Try adding the characters from the provided string to the font asset.
Declaration
public bool TryAddCharacters(string characters, out string missingCharacters)
Parameters
Type |
Name |
Description |
System.String |
characters |
String containing the characters to add to the font asset.
|
System.String |
missingCharacters |
String containing the characters that could not be added to the font asset.
|
Returns
Type |
Description |
System.Boolean |
Returns true if all the characters were successfully added to the font asset. Return false otherwise.
|
TryAddCharacters(UInt32[])
Try adding the characters from the provided string to the font asset.
Declaration
public bool TryAddCharacters(uint[] unicodes)
Parameters
Type |
Name |
Description |
System.UInt32[] |
unicodes |
Array that contains the characters to add to the font asset.
|
Returns
Type |
Description |
System.Boolean |
Returns true if all the characters were successfully added to the font asset. Return false otherwise.
|
TryAddCharacters(UInt32[], out UInt32[])
Try adding the characters from the provided string to the font asset.
Declaration
public bool TryAddCharacters(uint[] unicodes, out uint[] missingUnicodes)
Parameters
Type |
Name |
Description |
System.UInt32[] |
unicodes |
Array that contains the characters to add to the font asset.
|
System.UInt32[] |
missingUnicodes |
Array containing the characters that could not be added to the font asset.
|
Returns
Type |
Description |
System.Boolean |
Returns true if all the characters were successfully added to the font asset. Return false otherwise.
|