mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +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: https://github.com/SerenityOS/serenity/commit/606c0e16726
|
@ -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…
Reference in a new issue