Nested Rich Text tags have odd behavior

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>

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>

Thanks!
Chris

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 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.

Thanks, I’ll give styles a look.

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

Make sure you test using the latest release of the TMP package which is version 1.4.1 for Unity 2018.3 & 2018.4.

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.

Can you provide me with an example?

When I set mesh.fontSize = 16 and set the text to the “not nested” from above, it has the same result as the “nested”.

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>ABCabc”

The “abc” will be at size 16.

Lastly “<size=16pt><font=“heebo”><size=40px><font=arial>ABCabcDEF”

DEF will remain at size 16 and using the heebo font.

<size=16pt><size=40px>ABC
\u200d<size=50px>DEF

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!

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
4734152--448550--upload_2019-7-10_17-41-39.png

WITHOUT RETURN AT END
4734152--448553--upload_2019-7-10_17-42-0.png

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.

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.

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.

Is there any further information I can provide that might help the troubleshooting?

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.

Thanks!!

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>

4954664--481700--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>

4954664--481697--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!

Sorry for reviving this thread, but I’m having similar problems with nested “line-height” parameter. I’m using Unity 2019.4.37f and TMP 2.2.0-preview3.

My example:
This text is in a TMP Text component with a style “body14”.

<style="h3">Header</style>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

My stylesheet:

h3:
opening tags: <size=18><line-height=100%>
closing tags: </line-height></size>

body14:
opening tags: <size=14><line-height=120%>
closing tags: </line-height></size>

The result is that the lorem ipsum text has line-height=100% while it should use the body14 style and should have line-height=120%.


8021867--1034552--upload_2022-4-7_13-32-42.png