mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
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.
This commit is contained in:
parent
d2195f8088
commit
dd8d65ada0
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue