Search Unity

Force a font to use fallbacks

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by rempelj, Aug 14, 2018.

  1. rempelj

    rempelj

    Joined:
    Aug 3, 2013
    Posts:
    47
    Hi, thanks for the awesome fallback system. It makes localization easier than ever.

    We are using custom fonts for English text. We use the Google Noto font to fallback into Asian languages. The issue is that our custom font does not mix well with the Noto font.

    This is what it looks like in Korean:



    This is how it should look:



    Here's how our fallbacks are set up (we have multiple different fonts set up this way):




    Ideally there would be a way to force a font to prioritize its fallbacks if certain conditions are met. The only solution I can think of is attaching a custom script to all of our Text objects that swaps out the font asset based on the current selected language, which is not ideal.

    Is there a standard solution for this problem? If not, consider this post a feature request!
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,180
    Just to make sure I understand correctly, you currently have a custom font for English to which you have assigned several fallbacks created from Google's Noto font or are these fallback font assets assigned as general fallbacks in the TMP Settings?

    When the primary font asset assigned to the text object is the English font and need to display a Korean character, this character comes from the Noto font asset which has been assigned as fallback to this English font asset. I presume this is the desired behavior. Correct?

    When the primary font asset assigned to the text object is Korean, you want it to use the English / Latin Noto character?

    If this is incorrect, please provide additional information on how you have this setup right now and how the system currently handles this vs. how / what you need it to do.
     
  3. rempelj

    rempelj

    Joined:
    Aug 3, 2013
    Posts:
    47
    I have a custom font for English/Latin to which I have assigned several fallbacks created from Google's Noto font. (No general fallbacks are used)


    Correct.


    No, the Korean font is never used as a primary font asset.


    I use the English/Latin font asset as the primary asset on all text objects. If Noto is used as a fallback to display a missing character, e.g. Korean, I want to display the English/Latin characters in Noto also, so that it matches the Korean font.

    So, essentially what I'm looking for is: When a fallback asset is used to display Korean, Chinese, Japanese, or Russian, I want the text to use fallbacks for all characters even if they are not missing. (or some other solution - whatever works!)
     
    Last edited: Aug 14, 2018
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,180
    I guess we need to talk through this one as I am not sure about how this could be handled.

    Let's assume you have a text object that contains "Hi 안녕" in this case, you would want the English / Latin font used for Hi and the Korean fallback for "안녕".

    However, if the text is "안녕 Hi", we want both the "Hi" and "안녕" to be using the characters from Noto. Correct?
     
  5. rempelj

    rempelj

    Joined:
    Aug 3, 2013
    Posts:
    47
    We want the "Hi" and "안녕" to be using the characters from Noto in both cases.

    Sorry, I think I am making it sound more complicated than it is. Basically, if Noto is used as a fallback, then use Noto for all characters.

    Edit: Keep in mind that Noto may be broken up into multiple font assets. (i.e. Noto-CJK-Symbols, Noto-Korean, Noto-Latin, etc.)
     
    Last edited: Aug 14, 2018
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,180
    Basically, you are looking for an option where the fallback system can be used per character or on an entire block of text.

    The option to apply the fallback to the entire block of text is only valid if one of the fallback contains all the requested characters.

    Would that work for your use case?
     
    Last edited: Aug 14, 2018
  7. rempelj

    rempelj

    Joined:
    Aug 3, 2013
    Posts:
    47
    It wouldn't work for Chinese, which is often broken into 4-5 fallback fonts. We also use fallbacks for some special characters.

    Unless...

    The option to apply the fallback to the entire block of text is only valid if one of the fallbacks, including nested fallbacks, contains all the requested characters.

    ^ I think this would work. Is that possible?
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,180
    The use case is now clear to me and I think it would be a nice feature addition.

    No promises on potential implementation but I'll most certainly think about this.