mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +00:00
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.
This commit is contained in:
parent
93c9344e35
commit
b71c7a6e44
32 changed files with 63 additions and 65 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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&)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue