Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question TMP Changing Font for Localize

Discussion in 'UGUI & TextMesh Pro' started by GustavNinja, Feb 17, 2021.

  1. GustavNinja

    GustavNinja

    Joined:
    Jun 13, 2016
    Posts:
    96
    I have been experimenting with changing fonts for different localize builds. Since the Font Asset Creater has no code api for building during a batch run I was experimenting with having a main font and several localized fonts that replace this font during build. My problem is that the Atlas id also needs to be changed and probably all materials also needs to change this as well.
    And I don't really want to change my guid since it's a big game so this will be quite troublesome.
    Really I want a system in which I can change it inside the editor when changing language so that the designers can also work with adjusting the UI accordingly. I wouldn't mind making a fallback system as well but this also seems quite tedious since I will probably get a lot of "TMP SubMeshUI" attached to scenes and prefabs when designers work.

    Has anyone done any font exchange with TMP? Or have any good tips on how to make this happen I would like some help on this part.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I think a potential solution will be to use some localization system such as Unity's in development localization tool or something like I2 Localization. Based on local selection, these systems handle not only switching resources such as font assets but also potential property changes on these objects, scenes, etc. which is often required in addition to changing a font asset for example.

    Let me know what you think about the above?

    In terms of the preparation of font assets, there are a few users who have implemented their own system. However, I acknowledge the lack of API support for such task right now.

    Note: It is currently possible to use the Font Asset API to create new font assets, use the AssetDatabase API to save these new asset as well as add as sub objects the material and texture. This also includes API functions to TryAddCharacters() to these font assets which combined with Multi Atlas should work pretty good.

    There may be some missing functionality but nothing that should be too difficult to expose.
     
    Last edited: Feb 17, 2021
  3. GustavNinja

    GustavNinja

    Joined:
    Jun 13, 2016
    Posts:
    96
    Thanks for the reply @Stephan_B

    We made our own Localization system based on TMP. So we can’t really switch to a new system.
    Currently we are on an older version of TMP 1.4.1 but will upgrade to the latest one in the spring.
    I'm currently almost done with a ok version with AssetDatabase API to move language specific Font Assets to the Main Font Asset, so I will try to get this to work first but I'm also interested in Multi Atlas.
    I read the initial post about Multi Atlas but is it usable with Static Font Asset? I wasn't quite sure about this.

    In our current system we have a Main Font with basic alphabet letters and numerals and a fallback font with a bunch of Kanji or special signs, with another fallback font with an encrypted dynamic font added in runtime to pick up the rest of unknown Kanjis that might popup. We're currently adding a new language that requires a different font so which is why I'm trying to replace 3 Font Assets with the main 3 Font Assets.