[haiku-3rdparty-dev] Know size of DrawString?

  • From: hey68 you <hey68you@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 15 Nov 2011 14:45:06 +0200

Hello,

Apologies if this question is trivial (or if I'm really going about this
all wrong)...

I have a BView (not a BStringView) on which I want to draw a string using a
certain font size and weight by calling for example:

DrawString(someBString.String(), BPoint(5.0,5.0));

The string contents will change and I need to adjust the size of the BView
based on the new string size.

Is there a way I can calculate how much space the newly drawn string will
occupy?

While we're at it, what about a way to center-align the drawn string within
the BView?

Thanks in advance,
hey68you

Other related posts: