Setting TMP Fallback Font failed to Refresh showing text in Unity 2023 and Unity6000 0b12

Hello everyone,

It seems that adjusting the order of Fallback Fonts via code does not refresh the font.
Even after adjusting and then searching for all TMP Text objects and calling tmpText.ForceMeshUpdate(true);//this worked in 2022, the font fails to refresh. Strangely enough, font refresh only seems to occur when manually adjusting the order in the Inspector.

I have tried similar methods, such as using TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, mainFont);//BY AI suggest to force the font refresh, but these attempts have been unsuccessful.

Has anyone else experienced a similar issue? Are there any alternative solutions or workarounds that you have found effective? Any insights or tips would be greatly appreciated!

bump due to no response for a week

Hello, I experienced the exact same issue as you.
While exploring the internal code, I luckily discovered a specific function, and calling it resolved the problem.

To get straight to the point, in my case, after modifying the fallback fonts, calling TMP_ResourceManager.ClearFontAssetGlyphCache() solved the issue.

I couldn’t find any examples of how to use this function through a search, but it seems to have been introduced in 2.2.0-preview.3.
Additionally, according to the Changelog for version 4.0.0-pre2, the function is described as follows:

Added ClearFontAssetGlyphCache() function to the TMP_ResourcesManager to enable clearing the font asset fallback glyph cache.

I hope this helps :blush:

1 Like

Thank you!

I reverted to an old Unity version after I posted this topic and received no response.

However, I recently found the solution myself (after the 6000 LTS release), but I totally forgot this topic.

My process of solving the problem is very similar to yours.

Thanks very much anyway, lol.

    public static void ForceUpdateAllTmpTextFont()
    {
        TMP_ResourceManager.ClearFontAssetGlyphCache();

        Resources.FindObjectsOfTypeAll<TMP_Text>().ForEach(t => t.ForceMeshUpdate(true));
    }
1 Like

Thats good news!

And yes, you’re right. In the Editor environment, simply calling ClearFontAssetGlyphCache works, but I just realized that in the build environment, also need to call ForceMeshUpdate lol

Thank you for sharing your usage example

1 Like

cool~ glad it helps