From b067e95b24d08b43420d13c5123a52a6b0f71dbf Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:10:57 +0200 Subject: [PATCH] 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 --- variants/sim/SimDisplayDriver.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/variants/sim/SimDisplayDriver.h b/variants/sim/SimDisplayDriver.h index bc04a48b..1d92fb77 100644 --- a/variants/sim/SimDisplayDriver.h +++ b/variants/sim/SimDisplayDriver.h @@ -264,6 +264,26 @@ public: // one .cpp would duplicate the font's static const tables in each). 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 { EM_ASM({ if (!Module.__simCtx) return;