diff --git a/Userland/Applications/Browser/ElementSizePreviewWidget.cpp b/Userland/Applications/Browser/ElementSizePreviewWidget.cpp index bd0f6197849..d02fb497ef6 100644 --- a/Userland/Applications/Browser/ElementSizePreviewWidget.cpp +++ b/Userland/Applications/Browser/ElementSizePreviewWidget.cpp @@ -24,7 +24,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event) auto content_size_text = DeprecatedString::formatted("{}x{}", m_node_content_width, m_node_content_height); int inner_content_width = max(100, font().width(content_size_text) + 2 * content_width_padding); - int inner_content_height = max(15, font().glyph_height() + 2 * content_height_padding); + int inner_content_height = max(15, font().pixel_size_rounded_up() + 2 * content_height_padding); auto format_size_text = [&](Web::CSSPixels size) { return DeprecatedString::formatted("{:.4f}", size); diff --git a/Userland/Applications/DisplaySettings/MonitorWidget.cpp b/Userland/Applications/DisplaySettings/MonitorWidget.cpp index 169178a860f..2a9c315cc8b 100644 --- a/Userland/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorWidget.cpp @@ -155,7 +155,7 @@ void MonitorWidget::paint_event(GUI::PaintEvent& event) // Render text label scaled with scale factor to hint at its effect. // FIXME: Once bitmaps have intrinsic scale factors, we could create a bitmap with an intrinsic scale factor of m_desktop_scale_factor // and that should give us the same effect with less code. - auto text_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::IntSize { painter.font().width(displayed_resolution_string) + 1, painter.font().glyph_height() + 1 }); + auto text_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::IntSize { painter.font().width(displayed_resolution_string) + 1, painter.font().pixel_size_rounded_up() + 1 }); GUI::Painter text_painter(*text_bitmap); text_painter.set_font(painter.font()); diff --git a/Userland/Applications/HexEditor/HexEditor.h b/Userland/Applications/HexEditor/HexEditor.h index 37797b3cf69..f5217160139 100644 --- a/Userland/Applications/HexEditor/HexEditor.h +++ b/Userland/Applications/HexEditor/HexEditor.h @@ -97,7 +97,7 @@ private: void scroll_position_into_view(size_t position); size_t total_rows() const { return ceil_div(m_content_length, m_bytes_per_row); } - size_t line_height() const { return font().glyph_height() + m_line_spacing; } + size_t line_height() const { return font().pixel_size_rounded_up() + m_line_spacing; } size_t character_width() const { return font().glyph_width('W'); } size_t cell_width() const { return character_width() * 3; } size_t offset_margin_width() const { return 80; } diff --git a/Userland/Applications/KeyboardMapper/KeyButton.cpp b/Userland/Applications/KeyboardMapper/KeyButton.cpp index 5c5b7abca6f..c7d7f74e725 100644 --- a/Userland/Applications/KeyboardMapper/KeyButton.cpp +++ b/Userland/Applications/KeyboardMapper/KeyButton.cpp @@ -41,7 +41,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event) if (text().is_empty() || text().bytes_as_string_view().starts_with('\0')) return; - Gfx::IntRect text_rect { 0, 0, static_cast(ceilf(font.width(text()))), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, static_cast(ceilf(font.width(text()))), font.pixel_size_rounded_up() }; text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center); painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right); diff --git a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp index 69d45e258b4..3ef735ddb15 100644 --- a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp +++ b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp @@ -47,7 +47,7 @@ void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event) auto text_rect = rect(); text_rect.set_y(bottom_arrow_rect.bottom()); - text_rect.set_height(font().glyph_height()); + text_rect.set_height(font().pixel_size_rounded_up()); } void DoubleClickArrowWidget::mousedown_event(GUI::MouseEvent&) diff --git a/Userland/Applications/SystemMonitor/GraphWidget.cpp b/Userland/Applications/SystemMonitor/GraphWidget.cpp index db06da11d43..54bcd577fbc 100644 --- a/Userland/Applications/SystemMonitor/GraphWidget.cpp +++ b/Userland/Applications/SystemMonitor/GraphWidget.cpp @@ -150,7 +150,7 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) continue; auto constrain_rect = inner_rect.shrunken(8, 8); auto text_rect = constrain_rect.translated(0, y).intersected(constrain_rect); - text_rect.set_height(font().glyph_height()); + text_rect.set_height(font().pixel_size_rounded_up()); auto text = format.text_formatter(current_values[i]); if (format.text_shadow_color != Color::Transparent) painter.draw_text(text_rect.translated(1, 1), text, Gfx::TextAlignment::CenterRight, format.text_shadow_color); diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp index 66d15297cbf..2eb501b6cf3 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp @@ -120,7 +120,7 @@ void DiffViewer::draw_line(GUI::Painter& painter, DeprecatedString const& line, size_t DiffViewer::line_height() const { - return font().glyph_height() + 4; + return font().pixel_size_rounded_up() + 4; } Gfx::IntRect DiffViewer::separator_rect() const diff --git a/Userland/Games/2048/BoardView.cpp b/Userland/Games/2048/BoardView.cpp index f48d700a72a..0ed39eb3b3d 100644 --- a/Userland/Games/2048/BoardView.cpp +++ b/Userland/Games/2048/BoardView.cpp @@ -51,7 +51,7 @@ void BoardView::pick_font() font_database.for_each_font([&](Gfx::Font const& font) { if (font.family() != "Liza" || font.weight() != 700) return; - auto size = font.glyph_height(); + auto size = font.pixel_size_rounded_up(); if (size * 2 <= m_cell_size && size > best_font_size) { best_font_name = font.qualified_name(); best_font_size = size; diff --git a/Userland/Games/BrickGame/BrickGame.cpp b/Userland/Games/BrickGame/BrickGame.cpp index 76b0a10f087..8d6fbe81ed2 100644 --- a/Userland/Games/BrickGame/BrickGame.cpp +++ b/Userland/Games/BrickGame/BrickGame.cpp @@ -502,10 +502,9 @@ void BrickGame::paint_text(GUI::Painter& painter, int row, DeprecatedString cons auto const text_width = static_cast(ceilf(font().width(text))); auto const entire_area_rect { frame_inner_rect() }; auto const margin = 4; - auto const glyph_height = font().glyph_height(); auto const rect { Gfx::IntRect { entire_area_rect.x() + entire_area_rect.width() - 116, - 2 * margin + entire_area_rect.y() + (glyph_height + margin) * row, - text_width, glyph_height } }; + 2 * margin + entire_area_rect.y() + (font().pixel_size_rounded_up() + margin) * row, + text_width, font().pixel_size_rounded_up() } }; painter.draw_text(rect, text, Gfx::TextAlignment::TopLeft, Color::Black); } diff --git a/Userland/Games/ColorLines/ColorLines.cpp b/Userland/Games/ColorLines/ColorLines.cpp index cae00b18aa5..0e1968aacc7 100644 --- a/Userland/Games/ColorLines/ColorLines.cpp +++ b/Userland/Games/ColorLines/ColorLines.cpp @@ -212,10 +212,9 @@ void ColorLines::paint_event(GUI::PaintEvent& event) // Draw score auto const score_text = MUST(String::formatted("{:05}"sv, m_score)); auto text_width = static_cast(ceilf(m_score_font->width(score_text))); - auto const glyph_height = m_score_font->glyph_height(); auto const score_text_rect = Gfx::IntRect { frame_inner_rect().top_left().translated(text_margin), - Gfx::IntSize { text_width, glyph_height } + Gfx::IntSize { text_width, font().pixel_size_rounded_up() } }; painter.draw_text(score_text_rect, score_text, Gfx::TextAlignment::CenterLeft, text_color); @@ -224,7 +223,7 @@ void ColorLines::paint_event(GUI::PaintEvent& event) text_width = m_score_font->width(high_score_text); auto const high_score_text_rect = Gfx::IntRect { frame_inner_rect().top_right().translated(-(text_margin + text_width), text_margin), - Gfx::IntSize { text_width, glyph_height } + Gfx::IntSize { text_width, font().pixel_size_rounded_up() } }; painter.draw_text(high_score_text_rect, high_score_text, Gfx::TextAlignment::CenterLeft, text_color); diff --git a/Userland/Games/Hearts/ScoreCard.cpp b/Userland/Games/Hearts/ScoreCard.cpp index 270744e6ce5..f8b934c80cb 100644 --- a/Userland/Games/Hearts/ScoreCard.cpp +++ b/Userland/Games/Hearts/ScoreCard.cpp @@ -26,7 +26,7 @@ Gfx::IntSize ScoreCard::recommended_size() return Gfx::IntSize { 4 * column_width + 3 * cell_padding, - 16 * card_font.glyph_height() + 15 * cell_padding + 16 * card_font.pixel_size_rounded_up() + 15 * cell_padding }; } void ScoreCard::paint_event(GUI::PaintEvent& event) @@ -42,9 +42,9 @@ void ScoreCard::paint_event(GUI::PaintEvent& event) auto cell_rect = [this, &font](int x, int y) { return Gfx::IntRect { frame_inner_rect().left() + x * column_width + x * cell_padding, - frame_inner_rect().top() + y * font.glyph_height() + y * cell_padding, + frame_inner_rect().top() + y * font.pixel_size_rounded_up() + y * cell_padding, column_width, - font.glyph_height(), + font.pixel_size_rounded_up(), }; }; @@ -74,8 +74,8 @@ void ScoreCard::paint_event(GUI::PaintEvent& event) auto score_text_width = static_cast(ceilf(font.width(score_text))); if (score_index != (int)player.scores.size() - 1) { painter.draw_line( - { text_rect.left() + text_rect.width() / 2 - score_text_width / 2 - 3, text_rect.top() + font.glyph_height() / 2 }, - { text_rect.right() - text_rect.width() / 2 + score_text_width / 2 + 3, text_rect.top() + font.glyph_height() / 2 }, + { text_rect.left() + text_rect.width() / 2 - score_text_width / 2 - 3, text_rect.top() + font.pixel_size_rounded_up() / 2 }, + { text_rect.right() - text_rect.width() / 2 + score_text_width / 2 + 3, text_rect.top() + font.pixel_size_rounded_up() / 2 }, text_color); } painter.draw_text(text_rect, diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp index 8bbea1dfe61..99036158f2f 100644 --- a/Userland/Games/MasterWord/WordGame.cpp +++ b/Userland/Games/MasterWord/WordGame.cpp @@ -60,7 +60,7 @@ void WordGame::pick_font() font_database.for_each_font([&](Gfx::Font const& font) { if (font.family() != "Liza" || font.weight() != 700) return; - auto size = font.glyph_height(); + auto size = font.pixel_size_rounded_up(); if (size * 2 <= m_letter_height && size > best_font_size) { best_font_name = font.qualified_name(); best_font_size = size; diff --git a/Userland/Libraries/LibCards/CardPainter.cpp b/Userland/Libraries/LibCards/CardPainter.cpp index 646ba1541a2..a95f7f3f5a3 100644 --- a/Userland/Libraries/LibCards/CardPainter.cpp +++ b/Userland/Libraries/LibCards/CardPainter.cpp @@ -201,7 +201,7 @@ void CardPainter::paint_card_front(Gfx::Bitmap& bitmap, Cards::Suit suit, Cards: paint_rect.set_height(paint_rect.height() / 2); paint_rect.shrink(10, 6); - auto text_rect = Gfx::IntRect { 4, 6, static_cast(ceilf(font.width("10"sv))), font.glyph_height() }; + auto text_rect = Gfx::IntRect { 4, 6, static_cast(ceilf(font.width("10"sv))), font.pixel_size_rounded_up() }; painter.draw_text(text_rect, card_rank_label(rank), font, Gfx::TextAlignment::Center, suit_color); painter.draw_bitmap( diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h index 50393041483..636ae23aa0f 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.h +++ b/Userland/Libraries/LibGUI/AbstractTableView.h @@ -24,7 +24,7 @@ public: class AbstractTableView : public AbstractView { public: - int row_height() const { return font().glyph_height() + vertical_padding(); } + int row_height() const { return font().pixel_size_rounded_up() + vertical_padding(); } virtual int horizontal_padding() const { return m_horizontal_padding; } void set_horizontal_padding(int padding) { m_horizontal_padding = padding; } @@ -122,7 +122,7 @@ private: bool m_highlight_selected_rows { true }; int m_vertical_padding { 8 }; - int m_horizontal_padding { font().glyph_height() / 2 }; + int m_horizontal_padding { font().pixel_size_rounded_up() / 2 }; int m_tab_moves { 0 }; }; diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 286e2293555..324324a3a5d 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -30,8 +30,8 @@ public: m_label->set_text(Gfx::parse_ampersand_string(tooltip)); int tooltip_width = m_label->effective_min_size().width().as_int() + 10; int line_count = m_label->text().count("\n"sv); - int glyph_height = m_label->font().glyph_height(); - int tooltip_height = glyph_height * (1 + line_count) + ((glyph_height + 1) / 2) * line_count + 8; + int font_size = m_label->font().pixel_size_rounded_up(); + int tooltip_height = font_size * (1 + line_count) + ((font_size + 1) / 2) * line_count + 8; Gfx::IntRect desktop_rect = Desktop::the().rect(); if (tooltip_width > desktop_rect.width()) diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 99eaaa95456..8a96a5cb254 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -105,7 +105,7 @@ void Button::paint_event(PaintEvent& event) content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing()); } - Gfx::IntRect text_rect { 0, 0, static_cast(ceilf(font.width(text()))), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, static_cast(ceilf(font.width(text()))), font.pixel_size_rounded_up() }; if (text_rect.width() > content_rect.width()) text_rect.set_width(content_rect.width()); text_rect.align_within(content_rect, text_alignment()); diff --git a/Userland/Libraries/LibGUI/Calendar.cpp b/Userland/Libraries/LibGUI/Calendar.cpp index 73fc74d8a23..5d42dc2af91 100644 --- a/Userland/Libraries/LibGUI/Calendar.cpp +++ b/Userland/Libraries/LibGUI/Calendar.cpp @@ -484,7 +484,7 @@ void Calendar::paint_event(GUI::PaintEvent& event) x_offset, y_offset + 4, m_tiles[0][i].width - 4, - font().glyph_height() + 4); + font().pixel_size_rounded_up() + 4); if (width > 150 && height > 150) { set_font(extra_large_font); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index 2efdd54ec24..e63e3de1ab7 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -102,9 +102,9 @@ Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const int column = glyph % columns(); return Gfx::IntRect { column * (font().max_glyph_width() + m_horizontal_spacing), - row * (font().glyph_height() + m_vertical_spacing), + row * (font().pixel_size_rounded_up() + m_vertical_spacing), font().max_glyph_width() + m_horizontal_spacing, - font().glyph_height() + m_vertical_spacing + font().pixel_size_rounded_up() + m_vertical_spacing } .translated(frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value()); } @@ -136,7 +136,7 @@ void GlyphMapWidget::paint_event(PaintEvent& event) outer_rect.x() + m_horizontal_spacing / 2, outer_rect.y() + m_vertical_spacing / 2, font().max_glyph_width(), - font().glyph_height()); + font().pixel_size_rounded_up()); if (m_selection.contains(glyph)) { painter.fill_rect(outer_rect, is_focused() ? palette().selection() : palette().inactive_selection()); if (font().contains_glyph(glyph)) @@ -184,7 +184,7 @@ Optional GlyphMapWidget::glyph_at_position(Gfx::IntPoint position) const Gfx::IntPoint map_offset { frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value() }; auto map_position = position - map_offset; auto col = (map_position.x() - 1) / ((font().max_glyph_width() + m_horizontal_spacing)); - auto row = (map_position.y() - 1) / ((font().glyph_height() + m_vertical_spacing)); + auto row = (map_position.y() - 1) / ((font().pixel_size_rounded_up() + m_vertical_spacing)); auto glyph = row * columns() + col + m_active_range.first; if (row >= 0 && row < rows() && col >= 0 && col < columns() && glyph < m_glyph_count + m_active_range.first) return glyph; @@ -197,7 +197,7 @@ int GlyphMapWidget::glyph_at_position_clamped(Gfx::IntPoint position) const Gfx::IntPoint map_offset { frame_thickness() - horizontal_scrollbar().value(), frame_thickness() - vertical_scrollbar().value() }; auto map_position = position - map_offset; auto col = clamp((map_position.x() - 1) / ((font().max_glyph_width() + m_horizontal_spacing)), 0, columns() - 1); - auto row = clamp((map_position.y() - 1) / ((font().glyph_height() + m_vertical_spacing)), 0, rows() - 1); + auto row = clamp((map_position.y() - 1) / ((font().pixel_size_rounded_up() + m_vertical_spacing)), 0, rows() - 1); auto glyph = row * columns() + col + m_active_range.first; if (row == rows() - 1) glyph = min(glyph, m_glyph_count + m_active_range.first - 1); @@ -448,7 +448,7 @@ void GlyphMapWidget::keydown_event(KeyEvent& event) void GlyphMapWidget::did_change_font() { recalculate_content_size(); - vertical_scrollbar().set_step(font().glyph_height() + m_vertical_spacing); + vertical_scrollbar().set_step(font().pixel_size_rounded_up() + m_vertical_spacing); } void GlyphMapWidget::scroll_to_glyph(int glyph) @@ -458,9 +458,9 @@ void GlyphMapWidget::scroll_to_glyph(int glyph) int column = glyph % columns(); auto scroll_rect = Gfx::IntRect { column * (font().max_glyph_width() + m_horizontal_spacing), - row * (font().glyph_height() + m_vertical_spacing), + row * (font().pixel_size_rounded_up() + m_vertical_spacing), font().max_glyph_width() + m_horizontal_spacing, - font().glyph_height() + m_vertical_spacing + font().pixel_size_rounded_up() + m_vertical_spacing }; scroll_into_view(scroll_rect, true, true); } @@ -515,12 +515,12 @@ void GlyphMapWidget::recalculate_content_size() m_rows = ceil_div(m_glyph_count, m_columns); constexpr auto overdraw_margins = 2; - auto max_visible_rows = event_height / (font().glyph_height() + m_vertical_spacing); + auto max_visible_rows = event_height / (font().pixel_size_rounded_up() + m_vertical_spacing); m_visible_rows = min(max_visible_rows, m_rows); m_visible_glyphs = (m_visible_rows + overdraw_margins) * m_columns; int content_width = columns() * (font().max_glyph_width() + m_horizontal_spacing); - int content_height = rows() * (font().glyph_height() + m_vertical_spacing); + int content_height = rows() * (font().pixel_size_rounded_up() + m_vertical_spacing); set_content_size({ content_width, content_height }); scroll_to_glyph(m_active_glyph); @@ -590,7 +590,7 @@ void GlyphMapWidget::leave_event(Core::Event&) Optional GlyphMapWidget::calculated_min_size() const { auto scrollbar = vertical_scrollbar().effective_min_size().height().as_int(); - auto min_height = max(font().glyph_height() + m_vertical_spacing, scrollbar); + auto min_height = max(font().pixel_size_rounded_up() + m_vertical_spacing, scrollbar); auto min_width = font().max_glyph_width() + m_horizontal_spacing + width_occupied_by_vertical_scrollbar(); return { { min_width + frame_thickness() * 2, min_height + frame_thickness() * 2 } }; } diff --git a/Userland/Libraries/LibGUI/GroupBox.cpp b/Userland/Libraries/LibGUI/GroupBox.cpp index 6b4b2d1d734..5219680c578 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() ? static_cast(ceilf(font().glyph_height())) + 1 /*room for the focus rect*/ : 2), + (!m_title.is_empty() ? font().pixel_size_rounded_up() + 1 /*room for the focus rect*/ : 2), 2, 2, 2 @@ -37,13 +37,13 @@ void GroupBox::paint_event(PaintEvent& event) painter.add_clip_rect(event.rect()); Gfx::IntRect frame_rect { - 0, (!m_title.is_empty() ? font().glyph_height() / 2 : 0), - width(), height() - (!m_title.is_empty() ? static_cast(ceilf(font().glyph_height())) / 2 : 0) + 0, (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0), + width(), height() - (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0) }; Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2); if (!m_title.is_empty()) { - Gfx::IntRect text_rect { 6, 1, static_cast(ceilf(font().width(m_title) + 6)), font().glyph_height() }; + Gfx::IntRect text_rect { 6, 1, static_cast(ceilf(font().width(m_title) + 6)), font().pixel_size_rounded_up() }; painter.fill_rect(text_rect, palette().button()); painter.draw_text(text_rect, m_title, Gfx::TextAlignment::CenterLeft, palette().button_text()); } diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 4cc0da5836b..3445145af4c 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -379,7 +379,7 @@ Gfx::IntRect IconView::editing_rect(ModelIndex const& index) const return {}; auto& item_data = get_item_data(index.row()); auto editing_rect = item_data.text_rect; - editing_rect.set_height(font_for_index(index)->glyph_height() + 8); + editing_rect.set_height(font_for_index(index)->pixel_size_rounded_up() + 8); editing_rect.set_y(item_data.text_rect.y() - 2); return editing_rect; } @@ -425,13 +425,13 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con { auto item_rect = this->item_rect(item_index); item_data.icon_rect = Gfx::IntRect(0, 0, 32, 32).centered_within(item_rect); - item_data.icon_offset_y = -font.glyph_height() - 6; + item_data.icon_offset_y = -font.pixel_size_rounded_up() - 6; item_data.icon_rect.translate_by(0, item_data.icon_offset_y); 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() }; + item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.pixel_size_rounded_up() }; item_data.wrapped_text_lines.clear(); if ((unwrapped_text_width > available_width) && (item_data.selected || m_hovered_index == item_data.index || cursor_index() == item_data.index || m_always_wrap_item_labels)) { @@ -458,7 +458,7 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con item_data.text_rect.set_width(widest_line_width); item_data.text_rect.center_horizontally_within(item_rect); item_data.text_rect.intersect(item_rect); - item_data.text_rect.set_height(font.glyph_height() * item_data.wrapped_text_lines.size()); + item_data.text_rect.set_height(font.pixel_size_rounded_up() * item_data.wrapped_text_lines.size()); item_data.text_rect.inflate(6, 6); item_data.text_rect_wrapped = item_data.text_rect; } else { @@ -551,14 +551,14 @@ void IconView::paint_event(PaintEvent& event) // Item text would not fit in the item text rect, let's break it up into lines.. const auto& lines = item_data.wrapped_text_lines; - size_t number_of_text_lines = min((size_t)text_rect.height() / font->glyph_height(), lines.size()); + size_t number_of_text_lines = min((size_t)text_rect.height() / font->pixel_size_rounded_up(), lines.size()); size_t previous_line_lengths = 0; for (size_t line_index = 0; line_index < number_of_text_lines; ++line_index) { Gfx::IntRect line_rect; line_rect.set_width(text_rect.width()); - line_rect.set_height(font->glyph_height()); + line_rect.set_height(font->pixel_size_rounded_up()); line_rect.center_horizontally_within(item_data.text_rect); - line_rect.set_y(3 + item_data.text_rect.y() + line_index * font->glyph_height()); + line_rect.set_y(3 + item_data.text_rect.y() + line_index * font->pixel_size_rounded_up()); line_rect.inflate(6, 0); // Shrink the line_rect on the last line to apply elision if there are more lines. diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index 13e3b0de3c3..0ed82912479 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -117,7 +117,7 @@ void MessageBox::build() int text_width = widget->font().width(m_text); auto number_of_lines = m_text.split('\n').size(); - int padded_text_height = widget->font().glyph_height() * 1.6; + int padded_text_height = widget->font().pixel_size_rounded_up() * 1.6; int total_text_height = number_of_lines * padded_text_height; int icon_width = 0; diff --git a/Userland/Libraries/LibGUI/RadioButton.cpp b/Userland/Libraries/LibGUI/RadioButton.cpp index 0cc1923395a..7884677ac8b 100644 --- a/Userland/Libraries/LibGUI/RadioButton.cpp +++ b/Userland/Libraries/LibGUI/RadioButton.cpp @@ -51,7 +51,7 @@ void RadioButton::paint_event(PaintEvent& event) Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed()); - Gfx::IntRect text_rect { circle_rect.right() + 5 + horizontal_padding(), 0, static_cast(ceilf(font().width(text()))), font().glyph_height() }; + Gfx::IntRect text_rect { circle_rect.right() + 5 + horizontal_padding(), 0, static_cast(ceilf(font().width(text()))), font().pixel_size_rounded_up() }; text_rect.center_vertically_within(rect()); paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft); diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index 4c068b994f4..e4a54b330de 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -321,7 +321,7 @@ void TabWidget::paint_event(PaintEvent& event) painter.draw_text(tab_button_content_rect, m_tabs[i].title, m_text_alignment, palette().button_text(), Gfx::TextElision::Right); if (is_focused()) { - Gfx::IntRect focus_rect { 0, 0, min(tab_button_content_rect.width(), font().width(m_tabs[i].title)), font().glyph_height() }; + Gfx::IntRect focus_rect { 0, 0, min(tab_button_content_rect.width(), font().width(m_tabs[i].title)), font().pixel_size_rounded_up() }; focus_rect.align_within(tab_button_content_rect, m_text_alignment); focus_rect.inflate(6, 4); diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 3f801aa1c99..9cb591c8b7e 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1437,7 +1437,7 @@ Gfx::IntRect TextEditor::line_content_rect(size_t line_index) const { auto& line = this->line(line_index); if (is_single_line()) { - Gfx::IntRect line_rect = { content_x_for_position({ line_index, 0 }), 0, text_width_for_font(line.view(), font()), font().glyph_height() + 4 }; + Gfx::IntRect line_rect = { content_x_for_position({ line_index, 0 }), 0, text_width_for_font(line.view(), font()), font().pixel_size_rounded_up() + 4 }; line_rect.center_vertically_within({ {}, frame_inner_rect().size() }); return line_rect; } diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp index 9082392e08d..35b0037fe2e 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp @@ -27,11 +27,11 @@ WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString cons header_widget.set_layout(GUI::Margins { 15, 30, 0 }); m_title_label = header_widget.add