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>
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.
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.
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.
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>
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.
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>
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>
I will be removing the line-height functionality temporarily from my system until this is resolved.
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.