Class TMP_FontAsset
Inherited Members
Namespace: TMPro
Syntax
[Serializable]
[ExcludeFromPreset]
public class TMP_FontAsset : TMP_Asset
Fields
atlas
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 |
|---|---|
| Single |
boldStyle
Defines the dilation of the text when using bold style.
Declaration
public float boldStyle
Field Value
| Type | Description |
|---|---|
| Single |
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 |
|---|---|
| Single |
normalStyle
Defines the dilation of the text when using regular style.
Declaration
public float normalStyle
Field Value
| Type | Description |
|---|---|
| Single |
tabSize
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 |
|---|---|
| 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 |
|---|---|
| Int32 |
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 |
|---|---|
| Int32 |
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 |
|---|---|
| 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 |
|---|---|
| Dictionary<UInt32, 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 |
faceInfo
Information about the font's face.
Declaration
public FaceInfo faceInfo { get; set; }
Property Value
| Type | Description |
|---|---|
| FaceInfo |
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[] |
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<UInt32, 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 |
|---|---|
| Boolean |
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 |
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 |
|---|---|
| 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 |
|---|---|---|
| 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 |
|---|---|---|
| Font | font |
Returns
| Type | Description |
|---|---|
| TMP_FontAsset |
CreateFontAsset(Font, Int32, Int32, GlyphRenderMode, Int32, Int32, AtlasPopulationMode, Boolean)
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, bool enableMultiAtlasSupport = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | The source font file. |
| Int32 | samplingPointSize | The sampling point size. |
| Int32 | atlasPadding | The padding / spread between individual glyphs in the font asset. |
| GlyphRenderMode | renderMode | |
| Int32 | atlasWidth | The atlas texture width. |
| Int32 | atlasHeight | The atlas texture height. |
| AtlasPopulationMode | atlasPopulationMode | |
| Boolean | enableMultiAtlasSupport |
Returns
| Type | Description |
|---|---|
| TMP_FontAsset |
GetCharacters(TMP_FontAsset)
Function to extract all the characters from a font asset.
Declaration
public static string GetCharacters(TMP_FontAsset fontAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| TMP_FontAsset | fontAsset |
Returns
| Type | Description |
|---|---|
| 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
| Type | Name | Description |
|---|---|---|
| TMP_FontAsset | fontAsset |
Returns
| Type | Description |
|---|---|
| Int32[] |
HasCharacter(Char, Boolean, Boolean)
Function to check if 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 | |
| Boolean | searchFallbacks | |
| Boolean | tryAddCharacter |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Int32 | character |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| String | text | String containing the characters to check |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| String | text | String containing the characters to check. |
| List<Char> | missingCharacters | List of missing characters. |
Returns
| Type | Description |
|---|---|
| Boolean |
HasCharacters(String, out UInt32[], Boolean, Boolean)
Function to check if the characters in the given string are contained in the font asset with the option to also check its potential 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. |
| UInt32[] | missingCharacters | Array containing the unicode values of the missing characters. |
| Boolean | searchFallbacks | Determines if fallback font assets assigned to this font asset should be searched. |
| Boolean | tryAddCharacter |
Returns
| Type | Description |
|---|---|
| Boolean |
ReadFontAssetDefinition()
Declaration
public void ReadFontAssetDefinition()
TryAddCharacters(String, Boolean)
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. |
| Boolean | includeFontFeatures |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if all the characters were successfully added to the font asset. Return false otherwise. |
TryAddCharacters(String, out String, Boolean)
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. |
| Boolean | includeFontFeatures |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if all the characters were successfully added to the font asset. Return false otherwise. |
TryAddCharacters(UInt32[], Boolean)
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 |
|---|---|---|
| UInt32[] | unicodes | Array that contains the characters to add to the font asset. |
| Boolean | includeFontFeatures |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if all the characters were successfully added to the font asset. Return false otherwise. |
TryAddCharacters(UInt32[], out UInt32[], Boolean)
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 |
|---|---|---|
| UInt32[] | unicodes | Array that contains the characters to add to the font asset. |
| UInt32[] | missingUnicodes | Array containing the characters that could not be added to the font asset. |
| Boolean | includeFontFeatures |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if all the characters were successfully added to the font asset. Return false otherwise. |