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

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 15 Nov 2011 14:51:27 +0100

On 15.11.2011 14:40, Rene Gollent wrote:
On Tue, Nov 15, 2011 at 8:36 AM, Stephan Aßmus<superstippi@xxxxxx>  wrote:
What is "5.0"? This won't work. The vertical coordinate passed to DrawString

The 5.0 was from his original example, I assumed he simply meant
horizontally centered since all he was asking about was the width
calculation.

No problem. Some APIs like SWT use the top-left coordinate of the string bounds for their drawing operation. (Which only works, though, if the string bounds are based on the maximum height a string can have in the given font, not on the actual height of a particular string...) I thought maybe you mixed up another API. :-) In any case, his original code would have worked only for extremly small font sizes where the ascent is below 5 pixels height. Otherwise the font would have been cut off at the top. Or maybe he did not use the view bounds, but some modified rectangle layouted somewhere inside the view with room above.

Best regards,
-Stephan



Other related posts: