SDL does not create TrueType font

I'm not quite sure if this is the best place for this, but I can't think of anything better

I "made" a low resolution font . (bonus points if you know where it really is)

The font works fine in gedit: gedit

However, when trying to render a font using SDL_ttf, it works mostly, with the exception of a few multi-byte Unicode characters (in particular æ 'and' '), while other non-ASCII characters work fine. But (!) All these characters work fine with other fonts (I used DejaVu Sans)

My fontDejavu sans

The fact that other fonts work fine suggests that the code is not to blame, but just in case:

SDL_Surface *surf = TTF_RenderUTF8_Solid(this->font, (const char *)text, col); if (surf == nullptr) { fprintf(stderr, "Rendering text failed (%s)\n", TTF_GetError()); return; } if (surf->format->BitsPerPixel != 8 || surf->format->BytesPerPixel != 1) { fprintf(stderr, "Rendering text failed (Wrong surface format)\n"); return; } 

(text const uint8 *) None of these errors work, obviously

I noticed that these 2 characters, in particular, are wider than the rest, could this be to blame?

In the comment below, the font seems to work fine with the SDL_TTF "latin-1" demo:

working in demo

+6
source share
1 answer

I .. I don't know what happened. I just tried again and everything worked out fine.

enter image description here

I was so sure I checked that I was using the correct font. Or maybe I changed something when I created it

Thanks for the help regardless :)

+1
source

Source: https://habr.com/ru/post/973291/


All Articles