fix(eink): fix font layout and add Lemon font support to GxEPDDisplay

Layout fix: GxEPDDisplay was using proportional GFX fonts (FreeSans9pt/12pt)
for sizes 1 and 2, giving lineHeight=16/20 instead of the 8/16 the UI layout
expects (designed for the OLED's bitmap font). Replaced with the GFX built-in
6×8 bitmap font (size 1) and its 2× scaled variant 12×16 (size 2). Size 3
keeps FreeSans18pt for large headings. fontAscender updated accordingly:
built-in font cursor is top-left (offset=0), Lemon GFX font adds 8px,
only FreeSans18pt still adds 26px.

Lemon font: LemonFont.h already stores the font in GFXfont format, so
GxEPDDisplay can use it directly via display.setFont(&Lemon). Added
_use_lemon flag, setLemonFont() override, and size-1 font selection in
setTextSize()/startFrame(). Adafruit GFX handles UTF-8 decoding for GFX
fonts, so Unicode characters (Cyrillic etc.) render correctly. The FONT
setting in SettingsScreen now works on e-ink the same as on OLED.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-22 17:20:20 +02:00
co-authored by Claude Sonnet 4.6
parent 0b6aaff49b
commit 4c37986737
2 changed files with 27 additions and 11 deletions
+8 -2
View File
@@ -15,6 +15,7 @@
#include <CRC32.h>
#include "DisplayDriver.h"
#include "LemonFont.h"
#ifndef DISPLAY_ROTATION
#define DISPLAY_ROTATION 0
@@ -48,6 +49,7 @@ class GxEPDDisplay : public DisplayDriver {
#endif
bool _init = false;
bool _isOn = false;
bool _use_lemon = false;
uint16_t _curr_color;
CRC32 display_crc;
int last_display_crc_value = 0;
@@ -66,8 +68,12 @@ public:
// 1 = FreeSans9pt (lineH=16, charW≈9)
// 2 = FreeSansBold12pt (lineH=20, charW≈12)
// 3 = FreeSans18pt (lineH=28, charW≈17)
int getCharWidth() const override { return _text_sz == 3 ? 17 : _text_sz == 2 ? 12 : 9; }
int getLineHeight() const override { return _text_sz == 3 ? 28 : _text_sz == 2 ? 20 : 16; }
// Size 1: GFX built-in 6×8 (default) or Lemon 5×10 bitmap font — matches OLED metrics.
// Size 2: GFX built-in scaled 12×16 bitmap font.
// Size 3: FreeSans18pt proportional font for large headings.
int getCharWidth() const override { return _text_sz == 3 ? 17 : _text_sz == 2 ? 12 : (_use_lemon ? 5 : 6); }
int getLineHeight() const override { return _text_sz == 3 ? 28 : _text_sz == 2 ? 16 : (_use_lemon ? 10 : 8); }
void setLemonFont(bool enabled) override { _use_lemon = enabled; }
bool begin();