Skip to content

Commit fa32ef0

Browse files
authored
[gui] Fix non-ASCII filename rendering in TRootBrowser (#22455)
1 parent c09318e commit fa32ef0

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

graf2d/win32gdk/gdk/src/gdk/win32/gdkfont-win32.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,18 @@ gdk_wchar_text_handle(GdkFont * font,
16381638
list = list->next;
16391639
}
16401640

1641-
if (!list)
1642-
singlefont = NULL;
1641+
if (!list) {
1642+
/* No font matched the Unicode block exactly. Fall back to the first
1643+
* font in the font set to avoid silently dropping the character (the
1644+
* old behavior set singlefont = NULL and skipped rendering entirely).
1645+
* With added defensive null-checks, this ensures CJK and non-Latin
1646+
* text visibility without introducing regression risks. */
1647+
if (private && private->fonts) {
1648+
singlefont = (GdkWin32SingleFont *) private->fonts->data;
1649+
} else {
1650+
singlefont = NULL;
1651+
}
1652+
}
16431653

16441654
GDK_NOTE(MISC,
16451655
g_print("%d:%d:%d ", start - wcstr, wcp - wcstr, block));

graf2d/win32gdk/gdk/src/gdk/win32/gdkim-win32.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,15 @@ gint gdk_mbstowcs(GdkWChar * dest, const gchar * src, gint dest_max)
291291

292292
/* A version that converts to wchar_t wide chars */
293293

294+
/* ROOT's application manifest explicitly declares <activeCodePage>UTF-8</activeCodePage>,
295+
* so strings entering the GDK backend are guaranteed to be valid UTF-8.
296+
* Use explicit UTF-8 decoding instead of mbstowcs(), which would
297+
* misinterpret the UTF-8 byte stream under the system's legacy ANSI code page. */
294298
gint
295299
gdk_nmbstowchar_ts(wchar_t * dest,
296300
const gchar * src, gint src_len, gint dest_max)
297301
{
298-
#if 1
302+
#if 0
299303
return mbstowcs(dest, src, src_len);
300304
#else
301305
wchar_t *wcp;

0 commit comments

Comments
 (0)