Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Localization and multiple font assets

Discussion in 'UGUI & TextMesh Pro' started by alan-lawrance, Jul 2, 2019.

  1. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    360
    What is the best practice for having multiple font assets for localization (e.g., one of Latin languages, one for Japanese, etc), and only loading the asset you need for the current language?

    A sledgehammer approach would be a FindObjectsByType to gather all TextMeshProGUI components and manually set the Font Asset, but I expect there is a better way to do this. I guess another option is to use an a single font asset that covers all languages, but that would be wasting memory.

    A TextMeshProUGI component points to Font Asset, but is there a way to globally set this asset for all TestMeshProUGUI components to use.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since localization most of the time also involves potentially changing images, sprites, etc. in addition to fonts, this is always best managed by some system / tools like for instance I2 Localization.

    In the absence of using a tool, you would have to create your own manager which would keep track of text objects in use in order to change what font asset they reference and other potential setting language related when language selection changes.

    I would suggest making sure the each Primary font asset for a given language is pre-configured with its own fallbacks.

    For Latin languages, your primary would contain all the known characters used in the project. It would be static to provide best performance. You would most likely also create a static font asset that contains all Cyrillic characters used / known in the project and assign it as fallback to your primary. You would then create a dynamic fallback also assign to the primary to catch / handle all user input / characters not already contained in the project.

    For instance, the Japanese primary font asset would contain all the known Japanese characters used in the project. This font asset would be static and have a dynamic fallback assigned to it to handle to user input / unknown characters. The same pattern would be used for Chinese and Korean.

    It is also a good idea to add the required characters used to display the language selection menu in either your primaries (if you have room) or in their own fallback. This way regardless of what language is selected, you have a font asset that contains the minimal set of characters to display the language selection menu.

    Most user also use AssetBundles to load the require font assets once a language selection has been made.
     
  3. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    360
    Thanks for this information -- and I see I2 Localization supports Text Mesh Pro!