Search Unity

Question (TMP) Fallback font & multi-language

Discussion in 'UGUI & TextMesh Pro' started by Bastienre4, Mar 10, 2021.

  1. Bastienre4

    Bastienre4

    Joined:
    Jul 8, 2014
    Posts:
    191
    Hello,

    We are trying to support mulitple languages in our game. We are using TMP fallback font assets.

    upload_2021-3-10_15-0-39.png

    Here's what we came with for now.

    upload_2021-3-10_14-59-11.png
    1 : Text with original font, without the need for the fallback
    2 : Text rendered with the original font that has fallback (original don't have any japanese characters)
    3 : Text rendered with the fallback font only (SourceHanSans)

    Notice the colon at line 2 : it's rendered with the original font instead of the Fallback font
    Notice the colon at line 3 : it's what we want

    We want to use the same font for all the text if there is a fallback without any missing character.
    How can we achieve this ?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I do not have a current solution for this other than using one of the HasCharacters() function as seen below to check if a given font asset contains all the requested characters.

    Code (csharp):
    1.  
    2. /// <summary>
    3. /// Function to check if certain characters exists in the font asset. Function returns a list of missing characters.
    4. /// </summary>
    5. /// <param name="text">String containing the characters to check.</param>
    6. /// <param name="missingCharacters">List of missing characters.</param>
    7. /// <returns></returns>
    8. public bool HasCharacters(string text, out List<char> missingCharacters)
    9.  
    This is not the first time this functionality has been requested and perhaps something that I could add support for.
     
    Bastienre4 likes this.
  3. Bastienre4

    Bastienre4

    Joined:
    Jul 8, 2014
    Posts:
    191
    Well, this looks like a good (needed ? :p) addition to TMP.
    Can I patch TMP myself to make this behaviour change easily?

    Thanks and have a nice day