Prechádzať zdrojové kódy

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.
Andreas Kling 3 rokov pred
rodič
commit
5c5e4b5ae5
1 zmenil súbory, kde vykonal 5 pridanie a 0 odobranie
  1. 5 0
      Userland/Libraries/LibGfx/Painter.cpp

+ 5 - 0
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();