Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of TTF_OpenFontRW is missing key info #267

Closed
vivaladav opened this issue Mar 1, 2023 · 1 comment
Closed

Documentation of TTF_OpenFontRW is missing key info #267

vivaladav opened this issue Mar 1, 2023 · 1 comment
Assignees
Milestone

Comments

@vivaladav
Copy link

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).

@slouken
Copy link
Collaborator

slouken commented Mar 1, 2023

It seems like for SDL_ttf 3.0 we should fix this behavior.

@slouken slouken self-assigned this Mar 1, 2023
@slouken slouken added this to the 3.0 milestone Mar 1, 2023
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.

Fixes libsdl-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.

Fixes libsdl-org#267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants