Opened 21 months ago
Last modified 20 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)
Change History (5)
by , 21 months ago
Attachment: | haiku-BMenuItem-centering-comparison.png added |
---|
comment:1 by , 21 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.
follow-up: 3 comment:2 by , 21 months ago
Component: | User Interface → Kits/Interface Kit |
---|---|
Owner: | changed from | to
if you already know what the fix would be why not submit it to review directly? :)
comment:3 by , 21 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 , 20 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.
Left is current, Right is fixed