Change Font for all TextMeshProUGUI at runtime

Is there any way to change the font for all TextMeshProUGUI at runtime? For example, when user change the language of the game, it will load up the best AtlasFontAsset for that language and use that to display the text.

Manually GetComponents<> and change them in OnEnable seems a little tedious to me :smile:, is there a hidden way of this feature already integrated in TextMeshPro?

There are different ways to handle this. Many users use AssetStore tools like I2 Localization to manage language specific resources such as changing the text, font asset and other settings based on language selection.

Other users have implemented their own managers that keep track of text objects and handle changing relevant settings when a new language selection is made. All these custom implementation end up using some list or dictionary to track text objects in a project / scene / etc.

Thank you for your pointer, it currently what I’ve been using to change the font (somewhat more naive, tho, that is, use GetComponents and change the font in OnFontChangedEvent). But it would be a big help if we can have a sort of virtual wrapper font sit in-between the actual FontAsset and the TextMeshPro components. So if we want to change the font for all NORMAL text, we could just grab the NORMAL wrapper font, and change it to another FontAsset, then all the TMP components that use that wrapper font will have new FontAsset assigned. Is there any chance that this feature has already included in TextMeshPro?

Sorry to necro an old thread, but did you ever find a solution to this?

I’m in a situation where I might have to swap out fonts instead of relying on the Font Asset Fallback feature, due to various circumstances.

as a Unity user, you should know that there are things you just have to do it yourself, or go to AssetStore.
I hacked a ‘solution’ for that project’s requirement, and i’m afraid you will have to do it too since i don’t remember where it went :smile:.
the gist of it is to browse through the scenes, find TMP component and change the font one by one.

Better you create yourself a component with events and make TextMeshProUGIU as parent. Myself needed a solution I did this way.

public class TextMeshProUGUIGlobalFont: TMPro.TextMeshProUGUI
    {
        private static TMP_FontAsset _globalFontAsset;
        public static TMP_FontAsset GlobalFontAsset
        {
            get => _globalFontAsset;
            set
            {
                _globalFontAsset = value;
                OnGlobalFontChangedEvent?.Invoke();
              
            }
        }

        public static UnityEvent OnGlobalFontChangedEvent = new();

        protected override void OnEnable()
        {
            base.OnEnable();
          
            OnGlobalFontChangedEvent.AddListener(OnGlobalFontChanged);
            OnGlobalFontChanged();
        }

        protected override void OnDisable()
        {
            base.OnDisable();
          
            OnGlobalFontChangedEvent.RemoveListener(OnGlobalFontChanged);
        }

        void OnGlobalFontChanged()
        {
            if (GlobalFontAsset != null)
            {
                this.font = GlobalFontAsset;
            }

        }
    }
}

Now instead of the orginal one use TextMeshProUGUIGlobalFont. It contains event to set font. It will set while OnEnable().