Search Unity

TextMesh Pro Nested Rich Text tags have odd behavior

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by clevyr-chris, Jul 9, 2019.

  1. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    Unity 2018.3.3f1

    I'm using rich text tags to style text in a TMPuGUI component. When I nest them, things are... broken. Is this known behavior? Is there a simple fix for this? Is there a way to allow nested tags through some setting I've not found?

    NESTED

    <size=16pt><line-height=80%><font="heebo"><align="left"><size=40px><line-height=91%><cspace=0px><font=arial><color=#000000>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</color></font></cspace></line-height></size></align>
    </font></line-height></size>

    upload_2019-7-9_13-57-11.png

    NOT NESTED
    <align="left"><size=40px><line-height=91%><cspace=0px><font=arial><color=#000000>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</color></font></cspace></line-height></size></align>

    upload_2019-7-9_13-56-51.png

    Thanks!
    Chris
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Nesting should be working so I will take a closer look and provide feedback once I have more information.

    I would like to suggest you consider using the <style> tag which can also be nested. I have made additional improvements to the style tag which will be in the next release. So give that a try as well and let me know how that works.
     
  3. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    Thanks, I'll give styles a look.

    Also, setting the fontSize causes the same issue as nesting.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Make sure you test using the latest release of the TMP package which is version 1.4.1 for Unity 2018.3 & 2018.4.
     
  5. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    I'm on TMP 1.4.1 - same behavior. Due to the way the markdown comes from the servers, the style tag is infeasible. I'll hardcode some items with the style tags to get more information.
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Can you provide me with an example?
     
  7. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    When I set mesh.fontSize = 16 and set the text to the "not nested" from above, it has the same result as the "nested".
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    As per the above, if you have "<size=16pt><font="heebo"><size=40px><font=arial>ABC"

    ABC will be using Arial and be of size 40. Is that your expectation?

    Then if you have "<size=16pt><font="heebo"><size=40px><font=arial>ABC</size>abc"

    The "abc" will be at size 16.

    Lastly "<size=16pt><font="heebo"><size=40px><font=arial>ABC</size>abc</font>DEF"

    DEF will remain at size 16 and using the heebo font.
     
  9. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    <size=16pt><size=40px>ABC</size>
    \u200d<size=50px>DEF</size></size>

    I'm expecting ABC to be at 40px, DEF to be at 50px, and the line break and subsequent invisichar to be at 16pt. ABC and DEF are correctly sized, but there is extra space on the last wrapped line when I wrap it at 16pt to get the line breaks to size correctly.

    The problem is the extra space. I need to be able to set that space to be a fixed size. When I'm using the invisible character on a line, it's almost working, but not if i specify a size for that invisible character outside of the ABC and DEF specifications.

    Thanks!
     
  10. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    Another case of the oversized line-breaks. There is an extra return at the end of the data I'm receiving. I realize I could trim them off the end and I likely will; I'm hoping that additional information will help troubleshoot the issue of extra space between lines.


    <align="left"><size=40px><line-height=91%><cspace=1px><font=arial><color=#f6ff61>Mostly cloudy throughout the day.</color></font></cspace></line-height></size></align>



    WITH RETURN AT END
    upload_2019-7-10_17-41-39.png


    WITHOUT RETURN AT END
    upload_2019-7-10_17-42-0.png
     
  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    When you say "Extra return at the end", you mean extra line feed / char(10) / "/n". Correct?

    If so, if the text contains multiple line feeds, I can't ignore them nor remove them. If a line of text is affected by <line-height=x> this means each line should be spaced by x where a new line if the result of encountering a line feed or wrapping.

    My understanding of the issue right now is the inconsistent application of the line-height which I will be looking into. I just want to make sure that is the issue reported here.
     
  12. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    Yes to both - the "/n" at the end and that the issue is the inconsistent line-height that I original thought was due to nesting. However, the issue occurs in the last example, which has no nesting.

    The default TMP font size in the TMP settings file is 36. If the /n at the end of the line is causing issues with line-height, I could programmatically wrap the content of all code-generated TMPs in a <size="16"> - but then I run into the issue first described.
     
  13. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Thank you for taking the time to explain the issue. I should be able to look into it today and follow up with you afterwards.
     
  14. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    Is there any further information I can provide that might help the troubleshooting?
     
  15. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Just wanted to let you know that I have not forgotten about your report. Hoping to get back to it within the next few days / over the weekend.

    I should be good at this time. I'll let you know if I need anything else.
     
  16. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
  17. clevyr-chris

    clevyr-chris

    Joined:
    Apr 3, 2019
    Posts:
    11
    After experimentation, it looks like removing the line-height tag removes the issue.

    Incorrectly spaced:

    <align="left"><line-height=91%><cspace=0px><font=arial><color=#000000>A day without coffee is like...</color></font></cspace></align>
    <align="left"><line-height=91%><cspace=0px><font=arial><color=#000000>Just kidding, I</color></font></cspace></align>
    <align="left"><line-height=91%><cspace=0px><font=arial><color=#000000>have no idea.</color></font></cspace></align>

    upload_2019-9-11_12-57-41.png

    Correctly spaced:

    <align="left"><cspace=0px><font=arial><color=#000000>A day without coffee is like...</color></font></cspace></align>
    <align="left"><cspace=0px><font=arial><color=#000000>Just kidding, I</color></font></cspace></align>
    <align="left"><cspace=0px><font=arial><color=#000000>have no idea.</color></font></cspace></align>

    upload_2019-9-11_12-57-0.png


    I will be removing the line-height functionality temporarily from my system until this is resolved.

    Hope this helps!
     
    Last edited: Sep 11, 2019