[Haiku-commits] r21466 - in haiku/trunk: headers/os/interface src/kits/interface

Ingo Weinhold bonefish at cs.tu-berlin.de
Wed Jun 20 13:33:52 CEST 2007


On 2007-06-20 at 03:33:52 [+0200], Axel Dörfler <axeld at pinc-software.de> 
wrote:
> bonefish at BerliOS <bonefish at mail.berlios.de> wrote:
> > * The label is no longer drawn at vertical position font ascent +
> > descent
> >   + leading + 2 (not sure how this calculation was supposed to work),
> > but
> >   vertically centers the label around the ascent. With big fonts the
> > label is
> >   shown a bit too far to the bottom. Not sure how to fix this in a
> > generic way.
> 
> Since it's just centered, how does that happen? Or do you just mean
> that the menu item height is too small (which would be easily fixable,
> similar to what BButton is doing)?

I centered the ascent of the font, which I assumed, would look as it should:

		float y = floor((Bounds().Height() + fh.ascent) / 2);
		[...]
		DrawString(Label(), BPoint(x, y));

It seems the font ascent is greater than the actual height of capital 
letters, though. BButton uses the following method, which aligns ascent + 
descent:

		float y = Bounds().top
			+ (Bounds().Height() - fh.ascent - fh.descent) / 2
			+ fh.ascent + 1;

That looks better, but is still at least one pixel off for the big font. 
Removing the "+ 1" would help, but then the small font label is one pixel 
off. I've attached screen shots:

* align-ascent-small-font: Ascent alignment, small font. Using the BButton 
alignment method produces an identical result.

* align-ascent-big-font: Ascent alignment, big font.

* align-bbutton-big-font: BButton alignment, big font.

CU, Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: align-ascent-small-font
Type: image/png
Size: 1218 bytes
Desc: not available
URL: <https://lists.berlios.de/pipermail/haiku-commits/attachments/20070620/2e93c887/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: align-ascent-big-font
Type: image/png
Size: 1752 bytes
Desc: not available
URL: <https://lists.berlios.de/pipermail/haiku-commits/attachments/20070620/2e93c887/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: align-bbutton-big-font
Type: image/png
Size: 1756 bytes
Desc: not available
URL: <https://lists.berlios.de/pipermail/haiku-commits/attachments/20070620/2e93c887/attachment-0002.png>


More information about the Haiku-commits mailing list