Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/SDL3/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -3921,6 +3921,28 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"

/**
* A variable for disabling Unicode font support in the X11 toolkit.
*
* This hint should be set before creating a messagebox.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_VIDEO_X11_TOOLKIT_FONT_USE_LATIN "SDL_VIDEO_X11_TOOLKIT_FONT_USE_LATIN"

/**
* A variable forcing the font for the X11 toolkit.
*
* Please note, the toolkit uses font metrics for calculating the size of UI elements.
*
* Using this hint will cause Unicode font support to be disabled.
*
* This hint should be set before creating a messagebox.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_VIDEO_X11_TOOLKIT_FONT "SDL_VIDEO_X11_TOOLKIT_FONT"

/**
* A variable controlling whether touch should be enabled on the back panel of
* the PlayStation Vita.
Expand Down
19 changes: 19 additions & 0 deletions src/video/x11/SDL_x11toolkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {

static void X11Toolkit_InitWindowFonts(SDL_ToolkitWindowX11 *window)
{
const char *custom_font;

custom_font = SDL_GetHint(SDL_HINT_VIDEO_X11_TOOLKIT_FONT);
if (custom_font) {
window->utf8 = false;
window->font_set = NULL;
window->font_struct = X11_XLoadQueryFont(window->display, custom_font);
if (window->font_struct) {
return;
}
}

if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_TOOLKIT_FONT_USE_LATIN, false)) {
goto load_font_traditional;
}

#ifdef X_HAVE_UTF8_STRING
window->utf8 = true;
window->font_set = NULL;
Expand Down Expand Up @@ -372,6 +388,9 @@ static void X11Toolkit_InitWindowFonts(SDL_ToolkitWindowX11 *window)
char *font;

load_font_traditional:
#ifdef X_HAVE_UTF8_STRING
window->font_set = NULL;
#endif
window->utf8 = false;
SDL_asprintf(&font, g_ToolkitFontLatin1, G_TOOLKITFONT_SIZE * window->iscale);
window->font_struct = X11_XLoadQueryFont(window->display, font);
Expand Down
Loading