mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:17:34 +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
|
@ -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;
|
||||
|
|
|
@ -502,10 +502,9 @@ void BrickGame::paint_text(GUI::Painter& painter, int row, DeprecatedString cons
|
|||
auto const text_width = static_cast<int>(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<int>(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);
|
||||
|
||||
|
|
|
@ -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<int>(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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue