Explorar el Código

Userland: Use Font::pixel_size_rounded_up() in more places

Andreas Kling hace 2 años
padre
commit
508fb7e1e9

+ 1 - 1
Userland/Libraries/LibGUI/Button.cpp

@@ -280,7 +280,7 @@ Optional<UISize> Button::calculated_min_size() const
     if (!text().is_empty()) {
     if (!text().is_empty()) {
         auto& font = this->font();
         auto& font = this->font();
         horizontal = static_cast<int>(ceilf(font.width(text()))) + 2;
         horizontal = static_cast<int>(ceilf(font.width(text()))) + 2;
-        vertical = static_cast<int>(ceilf(font.pixel_size())) + 4; // FIXME: Use actual maximum total height
+        vertical = font.pixel_size_rounded_up() + 4; // FIXME: Use actual maximum total height
     }
     }
 
 
     if (m_icon) {
     if (m_icon) {

+ 2 - 2
Userland/Libraries/LibGUI/CheckBox.cpp

@@ -66,8 +66,8 @@ void CheckBox::paint_event(PaintEvent& event)
     if (m_checkbox_position == CheckBoxPosition::Left)
     if (m_checkbox_position == CheckBoxPosition::Left)
         text_rect.set_left(box_rect.right() + 1 + gap_between_box_and_rect());
         text_rect.set_left(box_rect.right() + 1 + gap_between_box_and_rect());
     text_rect.set_width(static_cast<int>(ceilf(font().width(text()))));
     text_rect.set_width(static_cast<int>(ceilf(font().width(text()))));
-    text_rect.set_top(height() / 2 - static_cast<int>(ceilf(font().pixel_size()) / 2));
-    text_rect.set_height(static_cast<int>(ceilf(font().pixel_size())));
+    text_rect.set_top(height() / 2 - font().pixel_size_rounded_up() / 2);
+    text_rect.set_height(font().pixel_size_rounded_up());
 
 
     if (fill_with_background_color())
     if (fill_with_background_color())
         painter.fill_rect(rect(), palette().window());
         painter.fill_rect(rect(), palette().window());

+ 1 - 1
Userland/Libraries/LibGUI/RadioButton.cpp

@@ -70,7 +70,7 @@ Optional<UISize> RadioButton::calculated_min_size() const
 {
 {
     auto const& font = this->font();
     auto const& font = this->font();
     int width = horizontal_padding() * 2 + circle_size().width() + static_cast<int>(ceilf(font.width(text())));
     int width = horizontal_padding() * 2 + circle_size().width() + static_cast<int>(ceilf(font.width(text())));
-    int height = max(22, max(static_cast<int>(ceilf(font.pixel_size())) + 8, circle_size().height()));
+    int height = max(22, max(font.pixel_size_rounded_up() + 8, circle_size().height()));
     return UISize(width, height);
     return UISize(width, height);
 }
 }
 
 

+ 1 - 1
Userland/Libraries/LibGUI/Tray.cpp

@@ -24,7 +24,7 @@ Tray::Tray()
 
 
 Gfx::IntRect Tray::Item::rect(Tray const& tray) const
 Gfx::IntRect Tray::Item::rect(Tray const& tray) const
 {
 {
-    int item_height = static_cast<int>(ceilf(tray.font().pixel_size())) + 12;
+    int item_height = tray.font().pixel_size_rounded_up() + 12;
     return Gfx::IntRect {
     return Gfx::IntRect {
         tray.frame_thickness(),
         tray.frame_thickness(),
         tray.frame_thickness() + static_cast<int>(index) * item_height,
         tray.frame_thickness() + static_cast<int>(index) * item_height,

+ 1 - 1
Userland/Libraries/LibGfx/ClassicWindowTheme.cpp

@@ -16,7 +16,7 @@ namespace Gfx {
 
 
 int ClassicWindowTheme::menubar_height() const
 int ClassicWindowTheme::menubar_height() const
 {
 {
-    return max(20, ceilf(FontDatabase::default_font().pixel_size()) + 6);
+    return max(20, FontDatabase::default_font().pixel_size_rounded_up() + 6);
 }
 }
 
 
 Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette) const
 Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette) const

+ 3 - 3
Userland/Libraries/LibGfx/Painter.cpp

@@ -1381,8 +1381,8 @@ void Painter::draw_emoji(IntPoint point, Gfx::Bitmap const& emoji, Font const& f
     IntRect dst_rect {
     IntRect dst_rect {
         point.x(),
         point.x(),
         point.y(),
         point.y(),
-        static_cast<int>(ceilf(font.pixel_size() * emoji.width() / emoji.height())),
-        static_cast<int>(ceilf(font.pixel_size())),
+        font.pixel_size_rounded_up() * emoji.width() / emoji.height(),
+        font.pixel_size_rounded_up(),
     };
     };
     draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
     draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
 }
 }
@@ -2461,7 +2461,7 @@ void Gfx::Painter::draw_ui_text(Gfx::IntRect const& rect, StringView text, Gfx::
     Optional<size_t> underline_offset;
     Optional<size_t> underline_offset;
     auto name_to_draw = parse_ampersand_string(text, &underline_offset);
     auto name_to_draw = parse_ampersand_string(text, &underline_offset);
 
 
-    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(name_to_draw))), static_cast<int>(ceilf(font.pixel_size())) };
+    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(name_to_draw))), font.pixel_size_rounded_up() };
     text_rect.align_within(rect, text_alignment);
     text_rect.align_within(rect, text_alignment);
 
 
     draw_text(text_rect, name_to_draw, font, text_alignment, color);
     draw_text(text_rect, name_to_draw, font, text_alignment, color);

+ 1 - 1
Userland/Libraries/LibVT/TerminalWidget.cpp

@@ -1202,7 +1202,7 @@ static void collect_font_metrics(Gfx::Font const& font, int& column_width, int&
 {
 {
     line_spacing = 4;
     line_spacing = 4;
     column_width = static_cast<int>(ceilf(font.glyph_width('x')));
     column_width = static_cast<int>(ceilf(font.glyph_width('x')));
-    cell_height = static_cast<int>(ceilf(font.pixel_size()));
+    cell_height = font.pixel_size_rounded_up();
     line_height = cell_height + line_spacing;
     line_height = cell_height + line_spacing;
 }
 }