fix(sim): accent-picker confirm was silently dropping the diacritic

Selecting a variant from the Hold-Enter accent popup (e.g. 'o' -> 'o with
acute') correctly stored the real UTF-8 character in the text buffer, but
the live-typing preview line rendered it as the plain base letter -- the
accent was invisible even though the data was right.

Root cause: DisplayDriver::translateUTF8ToBlocks() transliterates extended
Latin characters down to ASCII for display drivers whose font can't render
them; real boards with the pixel-perfect MiscFixedFont override it to a
plain passthrough once _single_font is set (SH1106Display.cpp etc).
SimDisplayDriverCanvas reuses that same MiscFixedFont/MiscFixedRenderer
(confirmed the popup's own preview renders diacritics correctly, since it
prints its own variants directly rather than through this path) but never
added the matching override, so every string routed through
translateUTF8ToBlocks() -- not just the keyboard preview -- silently lost
its diacritics.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-03 12:10:57 +02:00
co-authored by Claude Sonnet 5
parent 97a86216c6
commit b067e95b24
+20
View File
@@ -264,6 +264,26 @@ public:
// one .cpp would duplicate the font's static const tables in each). // one .cpp would duplicate the font's static const tables in each).
void print(const char* str) override; void print(const char* str) override;
// Real MiscFixedFont covers the full glyph set print() draws above, so
// unlike DisplayDriver's base assumption ("no extended glyphs -- fall back
// to transliterateCodepoint()'s ASCII substitution"), this driver never
// needs that. Matches a real board's SH1106Display/SSD1306Display, whose
// own translateUTF8ToBlocks() override (gated on _single_font) does the
// same plain passthrough once OLED_MISC_FIXED_FONT is enabled. Without
// this override here, anything routed through translateUTF8ToBlocks()
// (KeyboardWidget's live-typing preview line, screen titles, ...) would
// inherit the base class's ASCII transliteration and silently strip every
// accented character down to its plain-Latin base -- e.g. typing "ó" via
// the accent-picker popup would show "o" in the text-entry preview even
// though the popup itself (which prints its own variants directly, not
// through this path) and the underlying buffer both had it right.
void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) override {
size_t n = strlen(src);
if (n >= dest_size) n = dest_size - 1;
memcpy(dest, src, n);
dest[n] = '\0';
}
void fillRect(int x, int y, int w, int h) override { void fillRect(int x, int y, int w, int h) override {
EM_ASM({ EM_ASM({
if (!Module.__simCtx) return; if (!Module.__simCtx) return;