From 5c5e4b5ae52ad7da3c929958241e2c8d0d43719b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Mar 2022 03:01:09 +0200 Subject: [PATCH] Revert "LibGfx: Remove bogus baseline adjustment in Painter's draw_text_line()" This reverts commit 2b2915656dca747ef4415b9d59f6d1fd6e50bf24. While this adjustment is bogus, it is currently responsible for putting CenterLeft aligned scalable text in the right position. This is going to take a bunch of work to get right. --- Userland/Libraries/LibGfx/Painter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 3ad7fa88ac..8b68f22741 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1365,6 +1365,11 @@ void draw_text_line(IntRect const& a_rect, Utf8View const& text, Font const& fon VERIFY_NOT_REACHED(); } + if (is_vertically_centered_text_alignment(alignment)) { + int distance_from_baseline_to_bottom = (font.pixel_size() - 1) - font.baseline(); + rect.translate_by(0, distance_from_baseline_to_bottom / 2); + } + auto point = rect.location(); int space_width = font.glyph_width(' ') + font.glyph_spacing();