# TextNode.setWordwrap()

Hi everybody,

the manual for TextNode.setWordwrap() says:

void TextNode::set_wordwrap(float wordwrap);
Description: Sets the text up to automatically wordwrap when it exceeds the indicated width. This can be thought of as a right margin or margin width.

I don’t quite understand what it means though. Higher values lead to longer lines, that much is easy to find out. But what’s the wordwrap number in the first place? It doesn’t seem related to the maximum number of characters in a line nor seems to be intuitively related to panda units.

I.e. in this case:

aTextNode = TextNode(“test”)
aTextNode.setText(“Blah, blah, blab, blah”)
aTextNode.setWordwrap(1.0)

I would have expected that the text wraps as it exceed 1.0 panda units, but that doesn’t seem to be the case. I also can’t quite interpret the idea that it is the “right margin or margin width”. If that was the case, as the margin grows I’d expect the line length to shrink. Can somebody cast some light on this mysterious corner of Panda’s documentation?

It is Panda units. Remember that the Panda units are relative to the TextNode itself, including its own scale. So when you set the wordwrap to 1.0, you are setting the TextNode to a maximum of 1.0 Panda units, within its own scale. Since most fonts are 1.0 Panda units high, this gives you about the width of one capital letter.

David

Thanks David, that settles it. In my case the scale issue was compounded by the use of 72 point size. That would increase the size of the characters by a 7.2 factor which I then compensated scaling the node back down with a futher multiplier. From that point it wasn’t obvious how visually functional wordwrap value of 20 related back to the font object and the text node. Thank you again!