You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came here to report that TTF_OpenFontRW fails on multiple calls with the same SDL_RWops and requesting a smaller point size than the one(s) requested before, but apparently this is well know since #108 and it's some kind of accepted behavior.
Just as reference for people who might encounter the same issue, this is what happens on multiple calls:
SDL_RWops * data;
TTF_OpenFontRW(data, 0, 20); // OK
TTF_OpenFontRW(data, 0, 22); // OK
TTF_OpenFontRW(data, 0, 22); // OK
TTF_OpenFontRW(data, 0, 18); // ERROR: Couldn't load font file
To fix that your code needs to reset the SDL_RWops with SDL_RWseek before calling TTF_OpenFontRW.
I am not sure I understand why TTF_OpenFontRW can't call SDL_RWseek(RWops, 0, RW_SEEK_SET) itself, but if that's a design choice it should be documented or people will never have a clue until they find #108 (I didn't while I was trying to figure things out) or try to call SDL_RWseek like I did (but after wasting a lot of time debugging my code and trying other random things).
The text was updated successfully, but these errors were encountered:
We'll use an absolute offset from the beginning of the stream instead of the current offset at the time the font is opened. This can be set per-font using TTF_PROP_FONT_IOSTREAM_OFFSET_NUMBER if necessary.
Fixeslibsdl-org#267
slouken
added a commit
to slouken/SDL_ttf
that referenced
this issue
Sep 27, 2024
We'll use an absolute offset from the beginning of the stream instead of the current offset at the time the font is opened. This can be set per-font using TTF_PROP_FONT_IOSTREAM_OFFSET_NUMBER if necessary.
Fixeslibsdl-org#267
I came here to report that TTF_OpenFontRW fails on multiple calls with the same SDL_RWops and requesting a smaller point size than the one(s) requested before, but apparently this is well know since #108 and it's some kind of accepted behavior.
Just as reference for people who might encounter the same issue, this is what happens on multiple calls:
To fix that your code needs to reset the SDL_RWops with SDL_RWseek before calling TTF_OpenFontRW.
I am not sure I understand why TTF_OpenFontRW can't call SDL_RWseek(RWops, 0, RW_SEEK_SET) itself, but if that's a design choice it should be documented or people will never have a clue until they find #108 (I didn't while I was trying to figure things out) or try to call SDL_RWseek like I did (but after wasting a lot of time debugging my code and trying other random things).
The text was updated successfully, but these errors were encountered: