From dd8d65ada094e484f45a9de055967e807273ce73 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 6 Jan 2023 11:27:05 +0100 Subject: LibGUI: Tweak GUI::Label auto-sizing logic for floating point font sizes We have to ceil the font size or we risk being 1px too small. --- Userland/Libraries/LibGUI/Label.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index eb9bd8ae92..2a0bdf07ce 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -112,12 +112,12 @@ void Label::paint_event(PaintEvent& event) void Label::size_to_fit() { - set_fixed_width(font().width(m_text) + m_autosize_padding * 2); + set_fixed_width(static_cast(ceilf(font().width(m_text))) + m_autosize_padding * 2); } int Label::text_calculated_preferred_height() const { - return int(AK::ceil(Gfx::TextLayout(font(), Utf8View { m_text }, text_rect().to_type()).bounding_rect(Gfx::TextWrapping::Wrap, Gfx::Painter::LINE_SPACING).height())); + return static_cast(ceilf(Gfx::TextLayout(font(), Utf8View { m_text }, text_rect().to_type()).bounding_rect(Gfx::TextWrapping::Wrap, Gfx::Painter::LINE_SPACING).height())); } Optional Label::calculated_preferred_size() const -- cgit v1.2.3