Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

TextMesh Pro Import TMP font at runtime

Discussion in 'UGUI & TextMesh Pro' started by Creta_Park, Jun 10, 2021.

  1. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    76
    upload_2021-6-11_4-44-32.png

    I want to make it a community localizable environment through the example of a video game, Celeste's exposed language files.

    Is there way to import TMP fonts in streaming assets or creating font assets from streaming assets in runtime?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,570
    You can most certainly import font assets at runtime from Addressables, AssetBundles, etc.

    You can also create font assets at runtime using something similar to the following:

    Code (csharp):
    1.  
    2. // Get paths to OS Fonts
    3. string[] fontPaths = Font.GetPathsToOSFonts();
    4.  
    5. // Create new font object from one of those paths
    6. Font osFont = new Font(fontPaths[index]);
    7.  
    8. // Create new dynamic font asset
    9. TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(osFont);
    10.  
    The above is from the following thread which also discusses the new Dynamic OS Font Asset type coming in the next release.

    There is TMP_FontAsset API functions to add characters to font assets, etc.
     
    DrViJ and Creta_Park like this.
unityunity