diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index c7d2bb7d5c97a7..df0ace8e4c9d46 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -117,9 +117,7 @@ void Label::size_to_fit() int Label::text_calculated_preferred_height() const { - // FIXME: The 4 is taken from Gfx::Painter and should be available as - // a constant instead. - return Gfx::TextLayout(&font(), Utf8View { m_text }, text_rect()).bounding_rect(Gfx::TextWrapping::Wrap, 4).height(); + return Gfx::TextLayout(&font(), Utf8View { m_text }, text_rect()).bounding_rect(Gfx::TextWrapping::Wrap, Gfx::Painter::LINE_SPACING).height(); } Optional Label::calculated_preferred_size() const diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index c60480f8a95b79..47f4a80a1b20e9 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1686,11 +1686,10 @@ void Painter::do_draw_text(IntRect const& rect, Utf8View const& text, Font const TextLayout layout(&font, text, rect); - static int const line_spacing = 4; - int line_height = font.pixel_size() + line_spacing; + int line_height = font.pixel_size() + LINE_SPACING; - auto lines = layout.lines(elision, wrapping, line_spacing); - auto bounding_rect = layout.bounding_rect(wrapping, line_spacing); + auto lines = layout.lines(elision, wrapping, LINE_SPACING); + auto bounding_rect = layout.bounding_rect(wrapping, LINE_SPACING); switch (alignment) { case TextAlignment::TopCenter: diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/Painter.h index 845978ce1b243c..2a788e31e85abd 100644 --- a/Userland/Libraries/LibGfx/Painter.h +++ b/Userland/Libraries/LibGfx/Painter.h @@ -25,6 +25,8 @@ namespace Gfx { class Painter { public: + static constexpr int LINE_SPACING = 4; + explicit Painter(Gfx::Bitmap&); ~Painter() = default;