diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp index c5faad46dc0..ff53b73713f 100644 --- a/Widgets/Painter.cpp +++ b/Widgets/Painter.cpp @@ -3,7 +3,14 @@ #include "Widget.h" #include #include + +#if 0 #include "Peanut8x8.h" +#define FONT_NAMESPACE Peanut8x8 +#else +#include "Peanut8x10.h" +#define FONT_NAMESPACE Peanut8x10 +#endif Painter::Painter(Widget& widget) : m_widget(widget) @@ -43,29 +50,29 @@ void Painter::drawText(const Rect& rect, const String& text, TextAlignment align point = rect.location(); point.moveBy(m_widget.x(), m_widget.y());; } else if (alignment == TextAlignment::Center) { - int textWidth = text.length() * Peanut8x8::fontWidth; + int textWidth = text.length() * FONT_NAMESPACE::fontWidth; point = rect.center(); - point.moveBy(-(textWidth / 2), -(Peanut8x8::fontWidth / 2)); + point.moveBy(-(textWidth / 2), -(FONT_NAMESPACE::fontWidth / 2)); point.moveBy(m_widget.x(), m_widget.y()); } else { ASSERT_NOT_REACHED(); } - for (int row = 0; row < Peanut8x8::fontHeight; ++row) { + for (int row = 0; row < FONT_NAMESPACE::fontHeight; ++row) { int y = point.y() + row; dword* bits = scanline(y); for (unsigned i = 0; i < text.length(); ++i) { byte ch = text[i]; if (ch == ' ') continue; - if (ch < Peanut8x8::firstCharacter || ch > Peanut8x8::lastCharacter) { + if (ch < FONT_NAMESPACE::firstCharacter || ch > FONT_NAMESPACE::lastCharacter) { printf("Font doesn't have 0x%02x ('%c')\n", ch, ch); ASSERT_NOT_REACHED(); } - const char* fontCharacter = Peanut8x8::font[ch - Peanut8x8::firstCharacter]; - int x = point.x() + i * Peanut8x8::fontWidth; - for (unsigned j = 0; j < Peanut8x8::fontWidth; ++j) { - char fc = fontCharacter[row * Peanut8x8::fontWidth + j]; + const char* fontCharacter = FONT_NAMESPACE::font[ch - FONT_NAMESPACE::firstCharacter]; + int x = point.x() + i * FONT_NAMESPACE::fontWidth; + for (unsigned j = 0; j < FONT_NAMESPACE::fontWidth; ++j) { + char fc = fontCharacter[row * FONT_NAMESPACE::fontWidth + j]; if (fc == '#') bits[x + j] = color.value(); } diff --git a/Widgets/Peanut8x10.h b/Widgets/Peanut8x10.h new file mode 100644 index 00000000000..f55495a86e9 --- /dev/null +++ b/Widgets/Peanut8x10.h @@ -0,0 +1,1049 @@ +#pragma once + +namespace Peanut8x10 { + +static constexpr char firstCharacter = '!'; +static constexpr char lastCharacter = '~'; +static constexpr byte fontWidth = 8; +static constexpr byte fontHeight = 10; + +static constexpr const char* font[] { + + " ## " + " ## " + " ## " + " ## " + " ## " + " ## " + " " + " ## " + " ## " + " ", + + " ## ## " + " ## ## " + " # # " + " " + " " + " " + " " + " " + " " + " ", + + " # # " + " # # " + " ###### " + " # # " + " # # " + " # # " + " ###### " + " # # " + " # # " + " ", + + " # " + " #### " + " # # # " + " # # " + " #### " + " # # " + " # # # " + " #### " + " # " + " ", + + " " + " ## # " + " ## ## " + " ## " + " ## " + " ## " + " ## ## " + " # ## " + " " + " ", + + " " + " ## " + " # # " + " # # " + " ### " + " # # " + " # # #" + " # ## " + " ### #" + " ", + + " ## " + " ## " + " # " + " " + " " + " " + " " + " " + " " + " ", + + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " ", + + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " ", + + " " + " " + " " + " # " + " ##### " + " # " + " # # " + " " + " " + " ", + + " " + " " + " " + " # " + " # " + " ##### " + " # " + " # " + " " + " ", + + " " + " " + " " + " " + " " + " " + " " + " ## " + " ## " + " ", + + " " + " " + " " + " " + " " + " ##### " + " " + " " + " " + " ", + + " " + " " + " " + " " + " " + " " + " " + " ## " + " ## " + " ", + + " " + " # " + " ## " + " ## " + " ## " + " ## " + " ## " + " # " + " " + " ", + + " #### " + " # ## " + " # # # " + " # # # " + " # # # " + " # # # " + " ## # " + " ## # " + " #### " + " ", + + " # " + " ## " + " # # " + " # " + " # " + " # " + " # " + " # " + " ### " + " ", + + " #### " + " # # " + " # # " + " # # " + " # " + " # " + " # " + " # " + " ###### " + " ", + + " ###### " + " # " + " # " + " # " + " #### " + " # " + " # " + " # # " + " #### " + " ", + + " # " + " ## " + " # # " + " # # " + " # # " + " ###### " + " # " + " # " + " # " + " ", + + " ###### " + " # " + " # " + " # " + " ##### " + " # " + " # " + " # # " + " #### " + " ", + + " ## " + " ## " + " # " + " # " + " ##### " + " # # " + " # # " + " # # " + " #### " + " ", + + " ###### " + " # # " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " ", + + " #### " + " # # " + " # # " + " # # " + " #### " + " # # " + " # # " + " # # " + " #### " + " ", + + " #### " + " # # " + " # # " + " # # " + " ##### " + " # " + " # " + " ## " + " ## " + " ", + + " " + " " + " " + " ## " + " ## " + " " + " ## " + " ## " + " " + " ", + + " " + " " + " " + " ## " + " ## " + " " + " ## " + " ## " + " " + " ", + + " " + " ## " + " # " + " # " + " # " + " # " + " # " + " ## " + " " + " ", + + " " + " " + " " + " ###### " + " " + " ###### " + " " + " " + " " + " ", + + " " + " ## " + " # " + " # " + " # " + " # " + " # " + " ## " + " " + " ", + + " #### " + " # # " + " # # " + " # " + " # " + " ## " + " " + " ## " + " ## " + " ", + + " #### " + " # # " + " # # " + " # ### " + " # # # " + " # # # " + " # ### " + " # " + " #### " + " ", + + " #### " + " # # " + " # # " + " # # " + " ###### " + " # # " + " # # " + " # # " + "### ###" + " ", + + " ##### " + " # # " + " # # " + " # # " + " ###### " + " # # " + " # # " + " # # " + " ##### " + " ", + + " #### " + " # # " + " # " + " # " + " # " + " # " + " # " + " # # " + " #### " + " ", + + " ##### " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " ##### " + " ", + + " ###### " + " # # " + " # " + " # " + " #### " + " # " + " # " + " # # " + " ###### " + " ", + + " ###### " + " # # " + " # " + " # " + " ### " + " # " + " # " + " # " + " ### " + " ", + + " #### " + " # # " + " # " + " # " + " # ###" + " # # " + " # # " + " # # " + " #### " + " ", + + " # # " + " # # " + " # # " + " # # " + " ###### " + " # # " + " # # " + " # # " + " # # " + " ", + + " ### " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " ### " + " ", + + " ##### " + " # # " + " # " + " # " + " # " + " # " + " # " + " # # " + " ### " + " ", + + " ### ###" + " # # " + " # # " + " # # " + " ### " + " # # " + " # # " + " # # " + " ### ###" + " ", + + " ### " + " # " + " # " + " # " + " # " + " # " + " # " + " # # " + " ###### " + " ", + + " # # " + " ## ## " + " # ## # " + " # # " + " # # " + " # # " + " # # " + " # # " + "### ###" + " ", + + " # # " + " # # " + " ## # " + " # # # " + " # # # " + " # ## " + " # # " + " # # " + " # # " + " ", + + " #### " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " #### " + " ", + + " ##### " + " # # " + " # # " + " #### " + " # " + " # " + " # " + " # " + " ### " + " ", + + " #### " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # # " + " # # " + " ### # " + " ", + + " ##### " + " # # " + " # # " + " # # " + " #### " + " # # " + " # # " + " # # " + " ### #" + " ", + + " #### " + " # # " + " # " + " # " + " #### " + " # " + " # " + " # # " + " #### " + " ", + + "####### " + "# # # " + " # " + " # " + " # " + " # " + " # " + " # " + " ### " + " ", + + "### ###" + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " #### " + " ", + + "### ### " + " # # " + " # # " + " # # " + " # # " + " # # " + " # # " + " # " + " # " + " ", + + "### ###" + " # # " + " # # " + " # # " + " # # " + " # # " + " # ## # " + " ## ## " + " # # " + " ", + + "## ## " + " # # " + " # # " + " # # " + " # " + " # # " + " # # " + " # # " + "## ## " + " ", + + "## ## " + " # # " + " # # " + " # # " + " # " + " # " + " # " + " # " + " ### " + " ", + + " ###### " + " # # " + " # " + " # " + " # " + " # " + " # " + " # # " + " ###### " + " ", + + " #### " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " #### " + " ", + + " " + " # " + " ## " + " ## " + " ## " + " ## " + " ## " + " # " + " " + " ", + + " #### " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " #### " + " ", + + " # " + " # # " + " # # " + " " + " " + " " + " " + " " + " " + " ", + + " " + " " + " " + " " + " " + " " + " " + " " + " ###### " + " ", + + " ## " + " ## " + " " + " " + " " + " " + " " + " " + " " + " ", + + " " + " " + " " + " #### " + " # # " + " # # " + " # # " + " # ## " + " ### # " + " ", + + " # " + " # " + " # " + " ##### " + " # # " + " # # " + " # # " + " # # " + " ##### " + " ", + + " " + " " + " " + " #### " + " # # " + " # " + " # " + " # # " + " #### " + " ", + + " # " + " # " + " # " + " ##### " + " # # " + " # # " + " # # " + " # # " + " ##### " + " ", + + " " + " " + " " + " #### " + " # # " + " ###### " + " # " + " # " + " #### " + " ", + + " " + " ### " + " # " + " # " + " #### " + " # " + " # " + " # " + " ### " + " ", + + " " + " " + " " + " #### " + " # # " + " # # " + " # # " + " #### " + " # " + " #### ", + + " " + " # " + " # " + " # " + " ##### " + " # # " + " # # " + " # # " + " # # " + " ", + + " " + " # " + " " + " ### " + " # " + " # " + " # " + " # " + " ### " + " ", + + " " + " # " + " " + " ### " + " # " + " # " + " # " + " # " + " # " + " ## ", + + "### " + " # " + " # " + " # " + " # ## " + " # # " + " ## # " + " # # " + "### # " + " ", + + " ## " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " ### " + " ", + + " " + " " + " " + " ## ## " + " # # #" + " # # #" + " # # #" + " # #" + " # #" + " ", + + " " + " " + " " + " ##### " + " # # " + " # # " + " # # " + " # # " + " # # " + " ", + + " " + " " + " " + " #### " + " # # " + " # # " + " # # " + " # # " + " #### " + " ", + + " " + " " + " " + " ##### " + " # # " + " # # " + " # # " + " ##### " + " # " + "### ", + + " " + " " + " " + " ##### " + " # # " + " # # " + " # # " + " ##### " + " # " + " ###", + + " " + " " + " " + " #### " + " # # " + " # " + " # " + " # " + "### " + " ", + + " " + " " + " " + " #### " + " ## # " + " # " + " # " + " # ## " + " #### " + " ", + + " " + " # " + " # " + " # " + " #### " + " # " + " # " + " # " + " ### " + " ", + + " " + " " + " " + " # # " + " # # " + " # # " + " # # " + " # # " + " #### #" + " ", + + " " + " " + " " + " # # " + " # # " + " # # " + " # # " + " # # " + " ## " + " ", + + " " + " " + " " + " # # #" + " # # #" + " # # #" + " # # #" + " # # #" + " ## ###" + " ", + + + " " + " " + " " + "### ###" + " # # " + " ## " + " ## " + " # # " + "### ###" + " ", + + " " + " " + " " + " # # " + " # # " + " # # " + " # # " + " ##### " + " # " + " #### ", + + " " + " " + " " + " ###### " + " # " + " # " + " # " + " # " + " ###### " + " ", + + " " + " ## " + " # " + " # " + " # " + " # " + " # " + " ## " + " " + " ", + + " " + " # " + " # " + " # " + " # " + " # " + " # " + " # " + " " + " ", + + " " + " ## " + " # " + " # " + " # " + " # " + " # " + " ## " + " " + " ", + + " " + " " + " " + " " + " ## # " + " # ## " + " " + " " + " " + " ", +}; + +} + diff --git a/Widgets/TerminalWidget.cpp b/Widgets/TerminalWidget.cpp index 1053c32cc19..c6f7a2307ae 100644 --- a/Widgets/TerminalWidget.cpp +++ b/Widgets/TerminalWidget.cpp @@ -13,7 +13,7 @@ TerminalWidget::TerminalWidget(Widget* parent) { g_tw = this; - setRect({ 100, 300, columns() * 8, rows() * 8 }); + setRect({ 100, 300, columns() * 8, rows() * 10 }); printf("rekt: %d x %d\n", width(), height()); m_screen = new CharacterWithAttributes[rows() * columns()]; for (unsigned row = 0; row < m_rows; ++row) { @@ -64,11 +64,11 @@ void TerminalWidget::onPaint(PaintEvent&) char buf[2] = { 0, 0 }; for (unsigned row = 0; row < m_rows; ++row) { - int y = row * 8; + int y = row * 10; for (unsigned column = 0; column < m_columns; ++column) { int x = column * 8; buf[0] = at(row, column).character; - painter.drawText({ x, y, width(), 8 }, buf, Painter::TextAlignment::TopLeft, Color(0xa0, 0xa0, 0xa0)); + painter.drawText({ x, y, width(), 10 }, buf, Painter::TextAlignment::TopLeft, Color(0xa0, 0xa0, 0xa0)); } } } @@ -90,7 +90,7 @@ void TerminalWidget::onReceive(byte ch) auto addChar = [&] (byte ch) { at(m_cursorRow, m_cursorColumn).character = ch; - if (++m_cursorColumn > m_columns) { + if (++m_cursorColumn >= m_columns) { m_cursorColumn = 0; if (m_cursorRow < (m_rows - 1)) { ++m_cursorRow;