We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3571

Summary: X11 MessageBox doesn't work (can't load font) with UTF-8 system locale
Product: SDL Reporter: Rémi Verschelde <rverschelde>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.5   
Hardware: x86_64   
OS: Linux   
Attachments: Proposed patch based on comment 2

Description Rémi Verschelde 2017-01-27 19:45:54 UTC
I've noticed that SDL_ShowSimpleMessageBox doesn't work on my system (just returns -1 and "ERROR: Error Presenting MessageBox: No message system available".

I did some debugging (thanks to `./test/testmessage` which reproduces the issue for me) and narrowed it down to:
https://hg.libsdl.org/SDL/file/ca523d8f1af2/src/video/x11/SDL_x11messagebox.c#l197

```
static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";
static const char g_MessageBoxFont[] = "-*-*-*-*-*-*-*-120-*-*-*-*-*-*";

// [...]

data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont,
                                    &missing, &num_missing, NULL);
```

This call returns that it can't load the font g_MessageBoxFont. If I replace it with g_MessageBoxFontLatin1, it works fine.
I do have xorg fonts installed. Tweaking g_MessageBoxFont to e.g. `"-*-*-medium-r-*--0-120-*-*-*-*-*-*"` also works for me, but I don't know how to compose those xorg font declarations properly.

The issue is reproducible only when using my system locale (fr_FR.UTF-8) or another installed locale (en_US.UTF-8). It can't be reproduced when using C or C.UTF-8.

I understand that this might be a distro issue we need to fix on our end, but I prefer to start reporting it here to get additional input about it.

System: Mageia 6 x86_64
Linux 4.9.6
X11 1.19.1
Comment 1 Sam Lantinga 2017-01-28 02:18:02 UTC
Does it work to just have this?
"-*-*-*-*-*--*-120-*-*-*-*-*-*"

What about this?
"-*-*-*-*-*--0-120-*-*-*-*-*-*"

This is useful info about those font descriptions:
https://wiki.archlinux.org/index.php/X_Logical_Font_Description
Comment 2 Rémi Verschelde 2017-01-28 09:42:36 UTC
Thanks for the resource, as always the Arch wiki is quite helpful :)

The two suggestions from comment 1 don't work for me. This seems to be the minimal working font description on my system:

(1) "-*-*-medium-*-*--*-120-*-*-*-*-*-*"

It however defaults to an italic font, and this the Arch wiki says for slant "Usually this needs to be specified.", I guess this would be better:

(2) "-*-*-medium-r-*--*-120-*-*-*-*-*-*"

For the next argument setwidth_name, the wiki mentions that "A value should be set, not wildcarded, when there are two or more possible values.", so maybe this would be better:

(3) "-*-*-medium-r-normal--*-120-*-*-*-*-*-*"

For this setup, xfontsel says that 374 names match on my system, so I suppose it's still generic enough to work on most systems. To compare with the Latin1 font used currently:

g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";

So unless there's a strong reason not to specify the  weight_name, slant and setwidth_name, I guess the above proposal (3) would solve the bug for me (and hopefully not introduce regressions on other systems).
Comment 3 Rémi Verschelde 2017-01-28 09:43:16 UTC
For the reference, here are the x11 font packs I have installed currently:

$ rpm -qa | grep x11-font | sort
x11-font-adobe-100dpi-1.0.3-6.mga6
x11-font-adobe-75dpi-1.0.3-6.mga6
x11-font-alias-1.0.3-7.mga6
x11-font-bh-100dpi-1.0.3-6.mga6
x11-font-bh-75dpi-1.0.3-6.mga6
x11-font-bh-lucidatypewriter-100dpi-1.0.3-6.mga6
x11-font-bh-lucidatypewriter-75dpi-1.0.3-6.mga6
x11-font-bitstream-100dpi-1.0.3-6.mga6
x11-font-bitstream-75dpi-1.0.3-6.mga6
x11-font-bitstream-type1-1.0.3-6.mga6
x11-font-cursor-misc-1.0.3-6.mga6
x11-font-daewoo-misc-1.0.3-6.mga6
x11-font-encodings-1.0.4-6.mga6
x11-font-isas-misc-1.0.3-6.mga6
x11-font-jis-misc-1.0.3-6.mga6
x11-font-misc-misc-1.1.2-6.mga6
x11-font-type1-1.0.0-13.mga6
x11-font-xfree86-type1-1.0.4-6.mga6

Out of those: http://madb.mageia.org/package/list/t_search/x11-font/release/cauldron/application/0
Comment 4 Rémi Verschelde 2017-01-28 09:55:56 UTC
Created attachment 2689 [details]
Proposed patch based on comment 2
Comment 5 Sam Lantinga 2017-01-28 19:14:59 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/f8343b61abf7