Search Unity

TextMesh Pro Issues with really small font sizes and auto sizing

Discussion in 'UGUI & TextMesh Pro' started by AcidArrow, Aug 6, 2018.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,723
    Is there a technical reason why TextMesh Pro is having issues autosizing with really small font sizes?

    I avoid using a canvas, so I use the normal 3d TextMesh Pro. And I often place 3d text in stuff like screens, which are realistically sized.

    So I often end up with text sizes of 0.08 or something like that.

    Also, since text length may vary depending to the localisation, I often rely on auto sizing to ensure text doesn't overflow from where it's supposed to be.

    And it seems that at really low values it's not handled super well.

    Here is an example:

    textmesh1.png

    Font size is at 0.08 and everything is well.

    Now let's add one more line.

    textmesh2.png

    It seems to have jumped at 0.05? Even though there is enough vertical space that a somewhat higher value would suffice.

    But it's still workable.

    Now let's add a few more lines until it can't fit vertically.

    textmesh3.png

    0? What? Why?

    Is it a precision issue?

    Is there a workaround?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    It is a precision issue as the auto sizing increases or decreases by 0.05. So you are up against that limit.

    I would suggest changing scaling on those object so you can end up with a more reasonable point size that are close in the teens.
     
    ffleschner and AcidArrow like this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,723
    Cool, thanks for the info, I guess I have some resizing to do :)
     
  4. ChisTaki

    ChisTaki

    Joined:
    Mar 13, 2021
    Posts:
    5
    Hi have you managed to find a solution other than rescalling as i have a situation as to fit the text into the camera it needs to be small atleast i think thats whats causing it to not display the text
    Thanks
     
  5. ChisTaki

    ChisTaki

    Joined:
    Mar 13, 2021
    Posts:
    5
    i found a way to achive something similar as just changing the original scaling made it too small even in the prefab
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,723
    I'm not sure if you have the same problem, but how I solved the issue I'm describing in this thread is by running a script that went through all the scenes, found all textmesh pro components and then did this:
    Code (csharp):
    1. if (allTMPro[i].fontSize < 2f)
    2. {
    3.     Debug.Log(allTMPro[i].gameObject.name + " is a very naughty boy. It must be... processed");
    4.     allTMPro[i].gameObject.transform.localScale *= 0.1f;
    5.     allTMPro[i].gameObject.GetComponent<RectTransform>().sizeDelta *= 10f;
    6.  
    7.     if (allTMPro[i].enableAutoSizing)
    8.     {
    9.         allTMPro[i].fontSizeMax *= 10f;
    10.         allTMPro[i].fontSizeMin *= 10f;
    11.     }
    12.     allTMPro[i].fontSize *= 10f;
    13. }