mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
Let widget have a font() instead of using Font::defaultFont() everywhere.
This commit is contained in:
parent
e5acbca0e8
commit
fc1facf5c0
8 changed files with 32 additions and 25 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue