From debbe1cf757416f089541eb87144271f00619094 Mon Sep 17 00:00:00 2001
From: Volian0 <[EMAIL REDACTED]>
Date: Tue, 4 Mar 2025 17:29:08 +0100
Subject: [PATCH] Fix for Message Box failing to init on X11 (#12455)
Fixed X11 message boxes failing to initialize, because the proper X Logical Font Description could not be found
---
src/video/x11/SDL_x11messagebox.c | 34 ++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c
index a2fdba48c66c6..8aa1c6a82d212 100644
--- a/src/video/x11/SDL_x11messagebox.c
+++ b/src/video/x11/SDL_x11messagebox.c
@@ -48,13 +48,17 @@
static const char g_MessageBoxFontLatin1[] =
"-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";
-static const char g_MessageBoxFont[] =
- "-*-*-medium-r-normal--*-120-*-*-*-*-iso10646-1," // explicitly unicode (iso10646-1)
- "-*-*-medium-r-*--*-120-*-*-*-*-iso10646-1," // explicitly unicode (iso10646-1)
- "-*-*-*-*-*--*-*-*-*-*-*-iso10646-1," // just give me anything Unicode.
- "-*-*-medium-r-normal--*-120-*-*-*-*-iso8859-1," // explicitly latin1, in case low-ASCII works out.
- "-*-*-medium-r-*--*-120-*-*-*-*-iso8859-1," // explicitly latin1, in case low-ASCII works out.
- "-*-*-*-*-*--*-*-*-*-*-*-iso8859-1"; // just give me anything latin1.
+static const char* g_MessageBoxFont[] = {
+ "-*-*-medium-r-normal--*-120-*-*-*-*-iso10646-1", // explicitly unicode (iso10646-1)
+ "-*-*-medium-r-*--*-120-*-*-*-*-iso10646-1", // explicitly unicode (iso10646-1)
+ "-misc-*-*-*-*--*-*-*-*-*-*-iso10646-1", // misc unicode (fix for some systems)
+ "-*-*-*-*-*--*-*-*-*-*-*-iso10646-1", // just give me anything Unicode.
+ "-*-*-medium-r-normal--*-120-*-*-*-*-iso8859-1", // explicitly latin1, in case low-ASCII works out.
+ "-*-*-medium-r-*--*-120-*-*-*-*-iso8859-1", // explicitly latin1, in case low-ASCII works out.
+ "-misc-*-*-*-*--*-*-*-*-*-*-iso8859-1", // misc latin1 (fix for some systems)
+ "-*-*-*-*-*--*-*-*-*-*-*-iso8859-1", // just give me anything latin1.
+ NULL
+};
static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_COUNT] = {
{ 56, 54, 53 }, // SDL_MESSAGEBOX_COLOR_BACKGROUND,
@@ -200,13 +204,19 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox
if (SDL_X11_HAVE_UTF8) {
char **missing = NULL;
int num_missing = 0;
- data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont,
- &missing, &num_missing, NULL);
- if (missing) {
- X11_XFreeStringList(missing);
+ int i_font;
+ for (i_font = 0; g_MessageBoxFont[i_font]; ++i_font) {
+ data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont[i_font],
+ &missing, &num_missing, NULL);
+ if (missing) {
+ X11_XFreeStringList(missing);
+ }
+ if (data->font_set) {
+ break;
+ }
}
if (!data->font_set) {
- return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
+ return SDL_SetError("Couldn't load x11 message box font");
}
} else
#endif