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:
Andreas Kling 2020-09-19 18:32:10 +02:00
parent d3fcba78b0
commit 606c0e1672
Notes: sideshowbarker 2024-07-19 02:19:46 +09:00

View file

@ -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();