mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-01 17:56:12 +00:00
feat: runtime font switcher — Default vs Lemon in Settings > Display
- Add Lemon font (LemonFont.h, LemonIcons.h) to the standard build alongside the Adafruit built-in font; ~101 KB added to flash - SH1106Display: add _use_lemon flag + setLemonFont(bool) to switch at runtime; print() and getTextWidth() use Lemon path when active; translateUTF8ToBlocks() passes UTF-8 through unchanged (Lemon supports full Unicode U+0020-U+04FF) vs transliterating for the default font - DisplayDriver: add getCharWidth()/getLineHeight() virtuals (defaults 6/8); SH1106Display returns 5/9 for Lemon, 6/8 for default; add setLemonFont() no-op virtual; fix orphaned UTF-8 leading byte in drawTextEllipsized - FullscreenMsgView: replace fixed-char-count word-wrap with pixel-accurate wrap using display.getTextWidth(); use getLineHeight() for spacing so Lemon (9 px) and default (8 px) both render correctly - NodePrefs: add use_lemon_font field (0=default, 1=Lemon) - SettingsScreen: add "Font" item in Display section (Default / Lemon), calls UITask::applyFont() on change - UITask: add applyFont() that calls display->setLemonFont(use_lemon_font); called at startup (begin()) and when the setting changes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
72c07df8b3
commit
a115916d8f
@@ -27,6 +27,9 @@ public:
|
||||
virtual void drawRect(int x, int y, int w, int h) = 0;
|
||||
virtual void drawXbm(int x, int y, const uint8_t* bits, int w, int h) = 0;
|
||||
virtual uint16_t getTextWidth(const char* str) = 0;
|
||||
virtual int getCharWidth() const { return 6; } // typical character advance width (px)
|
||||
virtual int getLineHeight() const { return 8; } // pixel rows per text line
|
||||
virtual void setLemonFont(bool) { } // no-op; overridden by displays that support Lemon
|
||||
virtual void drawTextCentered(int mid_x, int y, const char* str) { // helper method (override to optimise)
|
||||
int w = getTextWidth(str);
|
||||
setCursor(mid_x - w/2, y);
|
||||
@@ -182,6 +185,10 @@ public:
|
||||
while (str_len > 0 && getTextWidth(temp_str) > max_width - ellipsis_width) {
|
||||
temp_str[--str_len] = 0;
|
||||
}
|
||||
// Strip orphaned UTF-8 leading byte left by byte-at-a-time trimming above.
|
||||
while (str_len > 0 && ((uint8_t)temp_str[str_len - 1] & 0xC0) == 0xC0) {
|
||||
temp_str[--str_len] = 0;
|
||||
}
|
||||
strcat(temp_str, ellipsis);
|
||||
|
||||
setCursor(x, y);
|
||||
|
||||
Reference in New Issue
Block a user