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

Unity UI SOLUTION: Missing UI FONT, Text does not display on Andriod devices

Discussion in 'UGUI & TextMesh Pro' started by LandonC, May 24, 2018.

  1. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    UPDATE!! EDITED

    Alright, so apparently I was wrong about my solution. Assigning the material to the font did not work. It only made the cause of the bug even more random, which is why I thought it was solved. I spent the whole night till morning and finally got rid of all of it with this solution.

    1. Make sure all fonts are initiated and set when the game starts. If you are changing the font in the text component with a script, make sure it is not initiated twice or in later game time, all fonts should be set the moment game starts. I have some of the gameObjects hidden and only enabled when player enables it, so I suspect my script collided with other scripts during Start() or Awake().

    2. This surprised me the most. Make sure your text component (Horizontal Overflow set as Wrap) width fits nicely with your Chinese or Japanese font, without any awkward spacing before it jumps to the next row. The bug will pop out when text exceeds three rows if this is not done.


    These are the conditions that would allow the bug to occur (in my case).
    1. The font has to be of foreign language(Japanese font or Chinese font).
    2. The text component's horizontal overflow is set as wrap and exceeds three rows of text.
    3. The font or text component is disabled when game begins and is only enabled during the game by player or text is updated on the text component by player.

    If you are facing this problem you may also refer to these few links that has similar issues, it might help you if my solution does not work. The first link shows a screenshot of the exact issue I faced.



    Anyone who understands the cause of this bug or has a better solution please do leave a reply.
    I would love to know more.

    Previous post (Incorrect method):
    Hi all! Are you struggling with UI fonts missing or not showing up on your android devices??
    I WAS. But after hours of trial and error, I finally found the culprit.

    Here's the simple fix if you changed the font during runtime.

    public Material fontMaterial;
    public Text text;
    public Font[] newFonts;

    void AvoidFontBug()
    {
    text.font = newFonts[0];
    text.material = fontMaterial;
    }

    That's it. Or if you did not change the font but still face this issue, just make sure you set a Material for your Text component. It worked for me.

    FYI, I'm using Unity 5.0 and my android devices are the Lenovo P1 and the Redmi Note 4x, android version 6.0.1 and android version 7.0. The font(.otf) could display Traditional Chinese and Japanese letters + Unicode, and is set as a dynamic font. Both had the same issue, the text just suddenly disappeared or becomes a distorted version of another font when new text components were initialized or text were updated by user input.
     
    Last edited: May 25, 2018
  2. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    I had the same problem.

    To resolve the issue I used best fit on the text settings to make sure there is a min and max font size to display.
     
    mehaeljenkin likes this.