dynamic font in input font tag

Hi, if i create a dynamic font at runtime by an OS font, can it be used in an input field tag ?
for example :
<font=“myDynamicFont”>some text

The newly created font asset will not be found.

However, you could use the OnFontAssetRequest delegate to get a callback whenever TMP is trying to load a font asset via tag where you could return this new font asset.

Alternatively, after you create this font asset, you could use the following function to register your font asset.

MaterialReferenceManager.AddFontAsset(newFontAsset);

Note: I do have plans to add a Resource Manager to TMP which will simplify this process. I am also planning on adding a new font asset type which will be “Dynamic OS” which I have described in a few posts on the forum already where this new font asset type will also simplify this process.

thank you for replying
i tried :

MaterialReferenceManager.AddFontAsset(newFontAsset);

but it did not work, in an input field i tried the <font=“theFontName”> but it was not recognized.

maybe i am doing something wrong
this is the way i create the font asset :

Font osFont = new Font(fontPaths[i]);
TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(osFont, 90, 10, UnityEngine.TextCore.LowLevel.GlyphRenderMode.SDFAA, 1024, 1024, AtlasPopulationMode.Dynamic);
fontAsset.name = "newfont";

MaterialReferenceManager.AddFontAsset(fontAsset);

can you please make a short example of how to use the : OnFontAssetRequest delegate ?
thank you very much

1 Like

This shows up on google when looking for examples, so to help future generations:

       // assign your font
        public TMP_FontAsset font;

        private void Start()
        {
            TMP_Text.OnFontAssetRequest += TMP_Text_OnFontAssetRequest;

        }

        private TMP_FontAsset TMP_Text_OnFontAssetRequest(int arg1, string arg2)
        {
             // args2 is the name that you are using on <font="this name"> if you need it
            return font;
        }