How to tell how wide a string is?


In a paint method, when using something like Graphics::drawFittedText() or any other text method available, is there a way to find out the width and height needed for a string? Or the width that the text method just used?

I’d like to draw some images following displaying some text, but I cannot figure out how to determine the width of the displayed string on the Graphics context.

[size=75](Searching on the forum did bring up a super funny thread from a disgruntled user last year about hinting, small font sizes, and low-res screens, but nothing that answered my question. Julian: thumbs up to you for locking that thread and leaving it there!)[/size]


There is Font::getStringWidth() for single-line text, or you could use a GlyphArrangement yourself, which has a getBoundingBox() function.


That looks perfect, thanks!