# How to tell how wide a string is?

**URL:** <https://forum.juce.com/t/how-to-tell-how-wide-a-string-is/10253>\
**Category:** General JUCE discussion\
**Created:** [April 8, 2013, 6:25am UTC](https://forum.juce.com/t/how-to-tell-how-wide-a-string-is/10253 "2013-04-08T06:25:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephanecharette](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephanecharette/32/83_2.png) [@stephanecharette](https://forum.juce.com/u/stephanecharette)\
**Post date:** [April 8, 2013, 6:25am UTC](https://forum.juce.com/t/how-to-tell-how-wide-a-string-is/10253/1 "2013-04-08T06:25:57Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![haydxn](https://avatars.discourse-cdn.com/v4/letter/h/5fc32e/32.png) [@haydxn](https://forum.juce.com/u/haydxn)\
**Post date:** [April 8, 2013, 7:43am UTC](https://forum.juce.com/t/how-to-tell-how-wide-a-string-is/10253/2 "2013-04-08T07:43:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stephanecharette](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephanecharette/32/83_2.png) [@stephanecharette](https://forum.juce.com/u/stephanecharette)\
**Post date:** [April 8, 2013, 8:29am UTC](https://forum.juce.com/t/how-to-tell-how-wide-a-string-is/10253/3 "2013-04-08T08:29:12Z")

</div>

> [@haydxn](#):
>
> There is Font::getStringWidth() for single-line text, …

That looks perfect, thanks!
