summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-06 11:27:05 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-06 12:02:20 +0100
commitdd8d65ada094e484f45a9de055967e807273ce73 (patch)
tree5b6b1ae25837525dbdccba85c6d30c5a6bc1b331 /Userland
parentd2195f8088be78b9243f920f55c52ad25a5510ff (diff)
downloadserenity-dd8d65ada094e484f45a9de055967e807273ce73.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/Label.cpp6
1 files changed, 3 insertions, 3 deletions
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 <kling@serenityos.org>
+ * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
* 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<int>(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<float>()).bounding_rect(Gfx::TextWrapping::Wrap, Gfx::Painter::LINE_SPACING).height()));
+ return static_cast<int>(ceilf(Gfx::TextLayout(font(), Utf8View { m_text }, text_rect().to_type<float>()).bounding_rect(Gfx::TextWrapping::Wrap, Gfx::Painter::LINE_SPACING).height()));
}
Optional<UISize> Label::calculated_preferred_size() const