Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Ellipsis and Truncate does not render anything

Discussion in 'UGUI & TextMesh Pro' started by castor76, Feb 22, 2021.

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    Using Unity 2021.b7 and TMPro 3.0.4

    When setting ellipsis or truncate on specific font, it does not display anything.
    I double check to make sure to have the ellipsis character included in the font.

    What else can possibly cause such disappearance?
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    Even forcing to type \u2026 in the text field does output ... ellipsis character.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Can you provide me with the raw text you are using and the font file?
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    Hi @Stephan_B , I have sent PM to you. Thanks.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Thank you for providing the font asset for me to look at.

    Inspecting the font asset, I can see the Ellipsis character and glyph is present in the font asset as seen below.

    upload_2021-2-22_23-6-36.png

    Creating a text object and referencing this character by using \u2026 does result in the Ellipsis being displayed as seen below.

    upload_2021-2-22_23-10-16.png

    and when I use the Overflow Ellipsis mode, it does show up as expected as seen below as well.

    upload_2021-2-22_23-10-56.png

    Since this glyph is 1 pixel in height, it is possible that due to UI scaling maybe it is not visible in the game view. Just for testing see if \u2026 will display as expected when creating a new text or scene.
     
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    upload_2021-2-23_16-25-33.png

    I can confirm and already told that \u2026 does print ellipsis character correctly without using actual ellipsis option.
    But turning the ellipsis option causes :

    upload_2021-2-23_16-26-47.png

    Truncate does the same thing :

    upload_2021-2-23_16-27-11.png
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    The whole TMP setting :
    upload_2021-2-23_16-28-56.png
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I believe the issue is related to the metrics of your font asset. More specifically the Ascent Line which in turn makes the line height larger than the RectTransform height of that object. Since there is no room to fit the text, it all gets truncated when using Ellipsis or Truncate mode.

    By adding the TMP_TextInfoDebugTool.cs script to your text object, you will be able to visualize the metrics of your font asset seen below. This script is contained in the TMP Examples & Extras.

    upload_2021-2-23_0-3-30.png

    As you can see the Ascent Line is very high which results in this truncation. The solution is for you to simply adjust the Ascent Line to a smaller value so that the text fits in the RectTransform.

    upload_2021-2-23_0-7-35.png

    Looking at the glyph metrics of most characters, their height is 7 which relative to the Ascent Line value of 16 results in this big gap at the top.
     
    Last edited: Feb 23, 2021
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,522
    Thanks for the info.

    My reason for setting the ascent value to 16 was because when I insert the sprite into text using tag with the same point size as the font size (16) only setting I could make sure that the sprite do look correct (pixel perfect with pixel size the same as the one with the font) if I reduce the ascent value, then the sprite tends to render smaller than it should be.

    The only seems like solution I got is to actually increase the textmeshpro UI element's height to say something like minimum of 20.

    I am not sure if this is the only viable solution... ?