diff options
author | Andreas Kling <kling@serenityos.org> | 2023-03-03 19:32:19 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-04 00:29:38 +0100 |
commit | b71c7a6e44981c35ae93c91944e6cff70006285d (patch) | |
tree | 0b7fc5d68ed0559ecf6ce4db9a7f18f3334e3ee8 /Userland/Applications | |
parent | 93c9344e3558fee71deb5067e68146582891b319 (diff) | |
download | serenity-b71c7a6e44981c35ae93c91944e6cff70006285d.zip |
Userland: Use Font::pixel_size_rounded_up() instead of glyph_height()
The only remaining clients of this API are specific to bitmap fonts and
editing thereof.
Diffstat (limited to 'Userland/Applications')
6 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Applications/Browser/ElementSizePreviewWidget.cpp b/Userland/Applications/Browser/ElementSizePreviewWidget.cpp index bd0f619784..d02fb497ef 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 169178a860..2a9c315cc8 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 37797b3cf6..f521716013 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 5c5b7abca6..c7d7f74e72 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<int>(ceilf(font.width(text()))), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, static_cast<int>(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 69d45e258b..3ef735ddb1 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 db06da11d4..54bcd577fb 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); |