diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 87913e6c15..99eaaa9545 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -279,8 +279,8 @@ Optional Button::calculated_min_size() const if (!text().is_empty()) { auto& font = this->font(); - horizontal = font.width(text()) + 2; - vertical = font.glyph_height() + 4; // FIXME: Use actual maximum total height + horizontal = static_cast(ceilf(font.width(text()))) + 2; + vertical = static_cast(ceilf(font.pixel_size())) + 4; // FIXME: Use actual maximum total height } if (m_icon) { diff --git a/Userland/Libraries/LibGUI/CheckBox.cpp b/Userland/Libraries/LibGUI/CheckBox.cpp index 34611c33fb..31349ecb39 100644 --- a/Userland/Libraries/LibGUI/CheckBox.cpp +++ b/Userland/Libraries/LibGUI/CheckBox.cpp @@ -42,9 +42,9 @@ void CheckBox::paint_event(PaintEvent& event) auto text_rect = rect(); if (m_checkbox_position == CheckBoxPosition::Left) text_rect.set_left(s_box_width + s_horizontal_padding); - text_rect.set_width(font().width(text())); - text_rect.set_top(height() / 2 - font().glyph_height() / 2); - text_rect.set_height(font().glyph_height()); + text_rect.set_width(static_cast(ceilf(font().width(text())))); + text_rect.set_top(height() / 2 - static_cast(ceilf(font().glyph_height()) / 2)); + text_rect.set_height(static_cast(ceilf(font().glyph_height()))); if (fill_with_background_color()) painter.fill_rect(rect(), palette().window()); @@ -85,7 +85,7 @@ void CheckBox::set_autosize(bool autosize) void CheckBox::size_to_fit() { - set_fixed_width(s_box_width + font().width(text()) + s_horizontal_padding * 2); + set_fixed_width(s_box_width + static_cast(ceilf(font().width(text()))) + s_horizontal_padding * 2); } } diff --git a/Userland/Libraries/LibGUI/GroupBox.cpp b/Userland/Libraries/LibGUI/GroupBox.cpp index 5f5b731ca5..9bc681d2ad 100644 --- a/Userland/Libraries/LibGUI/GroupBox.cpp +++ b/Userland/Libraries/LibGUI/GroupBox.cpp @@ -24,7 +24,7 @@ GroupBox::GroupBox(StringView title) Margins GroupBox::content_margins() const { return { - (!m_title.is_empty() ? font().glyph_height() + 1 /*room for the focus rect*/ : 2), + (!m_title.is_empty() ? static_cast(ceilf(font().glyph_height())) + 1 /*room for the focus rect*/ : 2), 2, 2, 2 @@ -38,7 +38,7 @@ void GroupBox::paint_event(PaintEvent& event) Gfx::IntRect frame_rect { 0, (!m_title.is_empty() ? font().glyph_height() / 2 : 0), - width(), height() - (!m_title.is_empty() ? font().glyph_height() / 2 : 0) + width(), height() - (!m_title.is_empty() ? static_cast(ceilf(font().glyph_height())) / 2 : 0) }; Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2); diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 1705a63ac1..4cc0da5836 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -428,7 +428,7 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con item_data.icon_offset_y = -font.glyph_height() - 6; item_data.icon_rect.translate_by(0, item_data.icon_offset_y); - int unwrapped_text_width = font.width(item_data.text); + int unwrapped_text_width = static_cast(ceilf(font.width(item_data.text))); int available_width = item_rect.width() - 6; item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.glyph_height() }; diff --git a/Userland/Libraries/LibGUI/RadioButton.cpp b/Userland/Libraries/LibGUI/RadioButton.cpp index cae14e4157..06c36e7012 100644 --- a/Userland/Libraries/LibGUI/RadioButton.cpp +++ b/Userland/Libraries/LibGUI/RadioButton.cpp @@ -66,7 +66,7 @@ Optional RadioButton::calculated_min_size() const int horizontal = 2 + 7, vertical = 0; auto& font = this->font(); vertical = max(font.glyph_height(), circle_size().height()); - horizontal += font.width(text()); + horizontal += static_cast(ceilf(font.width(text()))); return UISize(horizontal, vertical); }