Text wrapping issue - gap caused by premature wrapping

I noticed a block of space at the end of a ui text element for which I need to wrap text. I thought maybe I had set something up wrong, so I tried changing various things but couldn’t make it go away.

Then I noticed that if I moved the right anchor of the text element, decreasing its horizontal size, the gap shrank as the size decreased. I’m wondering if this might be some kind of error in the way the text width is calculated for wrapping, though I looked at UiTextComponent::CalculateHorizontalClipOffset() but I can’t get it to hit any breakpoints in the editor or in game.

Images:

Gap: https://imgur.com/a/GCc4Z

Smaller, no gap: http://i.imgur.com/iQKpksE.png

EDIT:

It might be important to note that I’m using “console” font, which is supposed to be a fixed-width font. It also seems that if I turn “wrap text” off and turn “clip text” on, the clipping can correctly find the edge of the element, so this does seem related to text wrapping rather than any issue with the ui setup.

This seems to be related to an interaction between whatever function is wrapping the text and the use of “console” font.

overflow, “wrap text”, console font --> Gap

“clip text”, no wrap, console font --> Works as expected

overflow, “wrap text”, default font --> Works as expected

“clip text”, no wrap, default font --> Works as expected

Hi @Catma - thanks for reporting this issue and for providing detailed information (and screenshots!) showing the problem - super useful!

We’re able to reproduce this issue also and have determined that this is being caused by the “pos” tag in the font XML file. Here’s the contents of console.font:

	<fontshader>
<font path="VeraMono.ttf" w="512" h="256"/>
<effect name="default">
<pass>
</pass>
<pass>
<color r="0" g="0" b="0" a="1"/>
<pos x="1" y="1"/>
</pass>
</effect>
<effect name="console">
<pass>
</pass>
<pass>
<color r="0" g="0" b="0" a="0.5"/>
<pos x="2" y="2"/>
</pass>
</effect>
</fontshader>

If you remove the “pos” tags in each of the (effect) “pass” fields, then the font should correctly wrap. This looks like a bug in the way the “pos” offset attribute is being applied during rendering.

If you don’t need any of the “effect” functionality provided by the font system, you could create a new font file that uses the same font (for example, ConsoleNoEffect.font):

	<fontshader>
<font path="VeraMono.ttf" w="512" h="256"/>
<effect name="default">
<pass>
</pass>
</effect>
</fontshader>

And that should wrap properly. Let us know if you still encounter issues and thanks again for reporting this!

This seems to have completely fixed the issue! I’ll report back if anything else comes up. Thanks for helping so fast!

Great! Please let us know if you encounter any other issues. Thanks!