Let widget have a font() instead of using Font::defaultFont() everywhere.

This commit is contained in:
Andreas Kling 2018-10-14 13:06:05 +02:00
commit fc1facf5c0
Notes: sideshowbarker 2024-07-19 18:48:22 +09:00
8 changed files with 32 additions and 25 deletions

View file

@ -14,9 +14,7 @@ TerminalWidget::TerminalWidget(Widget* parent)
{
g_tw = this;
auto& font = Font::defaultFont();
setWindowRelativeRect({ 0, 0, (columns() * font.glyphWidth()) + 4, (rows() * font.glyphHeight()) + 4 });
setWindowRelativeRect({ 0, 0, (columns() * font().glyphWidth()) + 4, (rows() * font().glyphHeight()) + 4 });
printf("rekt: %d x %d\n", width(), height());
m_screen = new CharacterWithAttributes[rows() * columns()];
@ -65,15 +63,13 @@ void TerminalWidget::paintEvent(PaintEvent&)
Painter painter(*this);
painter.fillRect(rect(), Color::Black);
auto& font = Font::defaultFont();
char buf[2] = { 0, 0 };
for (unsigned row = 0; row < m_rows; ++row) {
int y = row * font.glyphHeight();
int y = row * font().glyphHeight();
for (unsigned column = 0; column < m_columns; ++column) {
int x = column * font.glyphWidth();
int x = column * font().glyphWidth();
buf[0] = at(row, column).character;
painter.drawText({ x + 2, y + 2, width(), font.glyphHeight() }, buf, Painter::TextAlignment::TopLeft, Color(0xa0, 0xa0, 0xa0));
painter.drawText({ x + 2, y + 2, width(), font().glyphHeight() }, buf, Painter::TextAlignment::TopLeft, Color(0xa0, 0xa0, 0xa0));
}
}