Skip to content

Central/Eastern European (CE) national character support for embedded displays#1965

Open
stachuman wants to merge 2 commits intomeshcore-dev:mainfrom
stachuman:main
Open

Central/Eastern European (CE) national character support for embedded displays#1965
stachuman wants to merge 2 commits intomeshcore-dev:mainfrom
stachuman:main

Conversation

@stachuman
Copy link

Adds Central/Eastern European (CE) national character support for embedded displays using the Adafruit GFX 5x7 bitmap font.
Characters like Ą, Č, Ž, ß are rendered natively instead of being replaced with block characters.

What changed

  • New file: tools/generate_5x7_font.py — Python script that generates custom 5x7 font glyphs by compositing base CP437 letters with accent overlays (cedilla, ogonek, caron, acute, etc.)
  • New file: src/helpers/ui/locale_font.h — Generated header containing a replacement font[] array (105 national characters) and a mapCodepointToSlot() function for UTF-8 → font slot mapping
  • Modified: src/helpers/ui/DisplayDriver.h — translateUTF8ToBlocks() now decodes UTF-8 and maps codepoints to custom font slots when LOCALE_CE is defined
  • Modified: platformio.ini — Added -include src/helpers/ui/locale_font.h to base build flags
  • Modified: src/helpers/ui/E213Display.cpp, E290Display.cpp — Added cp437(true) to fix character rendering for slots >= 0xB0

Covered displays

  • SSD1306Display (OLED 128x64, e.g. Heltec V3/V4)
  • SH1106Display (OLED 128x64, e.g. Heltec V2)
  • ST7735Display (TFT, e.g. Heltec T114)
  • ST7789LCDDisplay (TFT, e.g. Heltec V4 TFT, T-Beam)
  • E213Display (E-ink 2.13", e.g. Wireless Paper, Vision Master)
  • E290Display (E-ink 2.9", e.g. Vision Master E290)

Supported languages

Polish, Czech, Slovak, Hungarian, Romanian, Croatian, Serbian (Latin), Slovenian, Bosnian, Turkish, Lithuanian, Latvian, Estonian, German (ß), and other languages using Latin-1 accented characters (French, Spanish, Portuguese, Italian, etc.)

How to use

Add -DLOCALE_CE to your build flags:

In your variant's platformio.ini:

build_flags =
${some_base.build_flags}
-DLOCALE_CE

Or pass it via environment variable:

PLATFORMIO_BUILD_FLAGS="-DLOCALE_CE" pio run -e your_target
When LOCALE_CE is not defined, behavior is completely unchanged — the original CP437 font loads as before.

How it works

The custom locale_font.h defines the FONT5X7_H header guard before Adafruit GFX's glcdfont.c is included, causing the original font to be skipped. The replacement font keeps ASCII (0x00-0x7F) identical to CP437 and places national characters in the 0x80+ slots. No display driver rendering code is changed — only the font data and UTF-8 translation function.

Staszek added 2 commits March 7, 2026 18:47
  - SSD1306Display (OLED 128x64, e.g. Heltec V3/V4)
  - SH1106Display (OLED 128x64, e.g. Heltec V2)
  - ST7735Display (TFT, e.g. Heltec T114)
  - ST7789LCDDisplay (TFT, e.g. Heltec V4 TFT, T-Beam)
  - E213Display (E-ink 2.13", e.g. Wireless Paper, Vision Master)
  - E290Display (E-ink 2.9", e.g. Vision Master E290)

  Not covered (different font systems):
  - ST7789Display (OLEDDisplay/ArialMT — use per-locale LOCALE_XX with generate_font_glyphs.py)
  - GxEPDDisplay (GxEPD2/FreeSans proportional font)
  - LGFXDisplay (LovyanGFX)

Locales supported for Poland, Czech Republic, Slovakia, Hungary, Romania, Croatia, Slovenia, Bosnia/Serbia/Montenegro, Turkey, Lithuania, Latvia, Estonia, German

Tested with Heltec V4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant