SDL_ttf icon indicating copy to clipboard operation
SDL_ttf copied to clipboard

Rendering text fails when NOT initializing with SDL_INIT_GAMECONTROLLER

Open hsbgit opened this issue 3 years ago • 5 comments

This is my current setup:

Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal Running in a virtualbox

I am using the official SDL2 packages from the Ubuntu repos -> libsdl2-ttf-2.0-0

I realized that my font is only visible when calling SDL_Init like this

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMECONTROLLER)

When I remove 'SDL_INIT_GAMECONTROLLER' my text is not rendered anymore.

Is this problem maybe related to this one: SDL_Init() with SDL_INIT_GAMECONTROLLER flag changes locale ?

I used the same code on past Ubuntu versions also with virtual box and it worked fine.

hsbgit avatar Dec 07 '21 08:12 hsbgit

Looks strange, it works without using SDL_INIT_GAMECONTROLLER can you check with latest version of SDL2 and SDL2_ttf

1bsyl avatar Dec 07 '21 09:12 1bsyl

It may take some time as I am currently quite busy... but I will try

hsbgit avatar Dec 09 '21 15:12 hsbgit

I suspect this is just an environment issue with your VM.

This code in hid_init() is probably what's fixing your font rendering:

    /* Set the locale if it's not set. */
    locale = setlocale(LC_CTYPE, NULL);
    if (!locale)
        setlocale(LC_CTYPE, "");

If you do this in the shell before running your test program, does it work? export LC_CTYPE=""

slouken avatar Dec 09 '21 17:12 slouken

setlocale(LC_CTYPE, "");

That doesn't mean "set locale to the empty string", it means "set locale to something determined by looking at environment variables".

smcv avatar Jun 29 '22 12:06 smcv

my font is only visible when...

What specific text are you rendering, and what specific API are you using to do it?

smcv avatar Jun 29 '22 12:06 smcv

There hasn't been any response, so I'm going ahead and closing this. Feel free to reopen it if you come back with more information.

slouken avatar Jan 15 '24 20:01 slouken