getTextWidth() includes carriage returns?


#1

I have a texteditor that resizes itself based on the size of its text using getTextWidth().

I've noticed that if I type a line, and then hit "return" to start a new line, this "return" counts as text at the end of that line and increases the "TextWidth" value, even though this "return" does not show up as visible text.

Is there anyway around this?


#2

If you use a GlyphArrangement, you can get it to give the bounding box excluding whitespace.


#3

(Or of course you could just do trim() before getting the string width!)