diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp index 31c918db58..e3c5d1b560 100644 --- a/SharedGraphics/Font.cpp +++ b/SharedGraphics/Font.cpp @@ -22,6 +22,7 @@ Font::Font(const char* const* glyphs, byte glyph_width, byte glyph_height, byte , m_first_glyph(first_glyph) , m_last_glyph(last_glyph) { + m_error_bitmap = CharacterBitmap::create_from_ascii(Peanut8x10::error_glyph, m_glyph_width, m_glyph_height); } Font::~Font() diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h index c420b8eef9..60b3863445 100644 --- a/SharedGraphics/Font.h +++ b/SharedGraphics/Font.h @@ -12,6 +12,7 @@ public: ~Font(); const CharacterBitmap* glyph_bitmap(byte) const; + const CharacterBitmap* error_bitmap() const { return m_error_bitmap.ptr(); } byte glyph_width() const { return m_glyph_width; } byte glyph_height() const { return m_glyph_height; } @@ -23,6 +24,7 @@ private: const char* const* m_glyphs { nullptr }; mutable RetainPtr m_bitmaps[256]; + RetainPtr m_error_bitmap; byte m_glyph_width { 0 }; byte m_glyph_height { 0 }; diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index 19586bc12b..ff20ed7a20 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -123,7 +123,7 @@ void Painter::draw_glyph(const Point& point, char ch, Color color) auto* bitmap = font().glyph_bitmap(ch); if (!bitmap) { dbgprintf("Font doesn't have 0x%b ('%c')\n", (byte)ch, ch); - ASSERT_NOT_REACHED(); + bitmap = font().error_bitmap(); } int x = point.x(); int y = point.y(); diff --git a/SharedGraphics/Peanut8x10.h b/SharedGraphics/Peanut8x10.h index 3a9d3a6b53..d5350fe738 100644 --- a/SharedGraphics/Peanut8x10.h +++ b/SharedGraphics/Peanut8x10.h @@ -7,6 +7,19 @@ static constexpr char last_glyph = '~'; static constexpr byte glyph_width = 8; static constexpr byte glyph_height = 10; +static constexpr const char* error_glyph { + " #### " + " # # " + " # # " + " # ## # " + " # ## # " + " #### " + " ## " + " ###### " + " ## " + " ## ", +}; + static constexpr const char* glyphs[] { " ## " diff --git a/SharedGraphics/Peanut8x8.h b/SharedGraphics/Peanut8x8.h index d4e9815a0b..23cb182f39 100644 --- a/SharedGraphics/Peanut8x8.h +++ b/SharedGraphics/Peanut8x8.h @@ -7,6 +7,17 @@ static constexpr char last_character = '~'; static constexpr byte font_width = 8; static constexpr byte font_height = 8; +static constexpr const char* error_glyph { + " #### " + " # # " + " # ## # " + " # ## # " + " #### " + " ## " + " ###### " + " ## ", +}; + static constexpr const char* font[] { " ## "