mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Userland: Use Font::pixel_size_rounded_up() in more places
This commit is contained in:
parent
2e2c717e89
commit
508fb7e1e9
|
@ -280,7 +280,7 @@ Optional<UISize> Button::calculated_min_size() const
|
|||
if (!text().is_empty()) {
|
||||
auto& font = this->font();
|
||||
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) {
|
||||
|
|
|
@ -66,8 +66,8 @@ void CheckBox::paint_event(PaintEvent& event)
|
|||
if (m_checkbox_position == CheckBoxPosition::Left)
|
||||
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_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())
|
||||
painter.fill_rect(rect(), palette().window());
|
||||
|
|
|
@ -70,7 +70,7 @@ Optional<UISize> RadioButton::calculated_min_size() const
|
|||
{
|
||||
auto const& font = this->font();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ Tray::Tray()
|
|||
|
||||
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 {
|
||||
tray.frame_thickness(),
|
||||
tray.frame_thickness() + static_cast<int>(index) * item_height,
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Gfx {
|
|||
|
||||
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
|
||||
|
|
|
@ -1381,8 +1381,8 @@ void Painter::draw_emoji(IntPoint point, Gfx::Bitmap const& emoji, Font const& f
|
|||
IntRect dst_rect {
|
||||
point.x(),
|
||||
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());
|
||||
}
|
||||
|
@ -2461,7 +2461,7 @@ void Gfx::Painter::draw_ui_text(Gfx::IntRect const& rect, StringView text, Gfx::
|
|||
Optional<size_t> 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);
|
||||
|
||||
draw_text(text_rect, name_to_draw, font, text_alignment, color);
|
||||
|
|
|
@ -1202,7 +1202,7 @@ static void collect_font_metrics(Gfx::Font const& font, int& column_width, int&
|
|||
{
|
||||
line_spacing = 4;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue