Opened 22 months ago

Last modified 21 months ago

#18294 new bug

Text not vertically aligned in BMenuItem

Reported by: accessays Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Interface Kit Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

After working with getting CalendarView centered, more things pop out as not being centered properly.

This time it's every single BMenuItem.

With default settings of "Noto Sans Display"@12pt, the rendering works out to be just fine. However, at 16pt, or changing to a different font like Inter, there is a 1px misalignment. See attached file for comparison -- left is current rendering @16pt, right is fixed.

I've confirmed that right rendering is, well, right :) by recreating BMenuItem in CSS and checking it in Chromium.

The issue comes from the following line:

fSuper->MovePenBy(0, menuPrivate.Ascent());

This takes neither padding (3px) nor border (2px) into account. The correct solution is

float height = menuPrivate.FontHeight() - menuPrivate.Padding().top * 2;
fSuper->MovePenBy(0, 2 + menuPrivate.Ascent() + (height - menuPrivate.FontHeight())/2.0);

which simplifies to

fSuper->MovePenBy(0, 2 + menuPrivate.Ascent() - menuPrivate.Padding().top);

I've tested "Noto Sans Display" at 12/16pt and Inter at 12/16pt and all render properly (i.e. same as Chromium) with the above change.

Attachments (1)

haiku-BMenuItem-centering-comparison.png (3.8 KB ) - added by accessays 22 months ago.
Left is current, Right is fixed

Download all attachments as: .zip

Change History (5)

by accessays, 22 months ago

Left is current, Right is fixed

comment:1 by accessays, 22 months ago

Looking closer, the icon (Alt) is also slightly misaligned -- it should be 1px higher as well.

And the text next to it (1) needs the same treatment as well.

comment:2 by nephele, 22 months ago

Component: User InterfaceKits/Interface Kit
Owner: changed from stippi to nobody

if you already know what the fix would be why not submit it to review directly? :)

in reply to:  2 comment:3 by accessays, 22 months ago

Replying to nephele:

if you already know what the fix would be why not submit it to review directly? :)

The icon and text next to it are still not aligned. Wanted to take a fresh look at this the next day.

comment:4 by jscipione, 21 months ago

I ran into the same issue with Tracker renaming files depending on font and font size the text box is sometimes off a pixel left or right compared to the file name string. The text should be in exactly the same location every time.

Note: See TracTickets for help on using tickets.