mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-19 07:49:05 +00:00
LibGfx: Move vertically centered text down slightly based on baseline
To make slightly more aesthetically pleasing use of the vertical space, we now move all vertically centered text lines down by half the amount of space below the font's baseline. This is probably not the "correct" way to do this, but it does make things look nicer with some of our fonts already.
This commit is contained in:
parent
d3fcba78b0
commit
606c0e1672
Notes:
sideshowbarker
2024-07-19 02:19:46 +09:00
Author: https://github.com/awesomekling
Commit: 606c0e1672
1 changed files with 5 additions and 0 deletions
|
@ -907,6 +907,11 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (is_vertically_centered_text_alignment(alignment)) {
|
||||
int distance_from_baseline_to_bottom = (font.glyph_height() - 1) - font.baseline();
|
||||
rect.move_by(0, distance_from_baseline_to_bottom / 2);
|
||||
}
|
||||
|
||||
auto point = rect.location();
|
||||
int space_width = font.glyph_width(' ') + font.glyph_spacing();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue