-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
TTF_OpenFontRW does not read in the full data? #164
Comments
This is less of a "this should behave differently" bug, because ctypes, and more of a "this is not documented in pysdl2 or sdl, and behaves differently from every other *RW function" |
ALSO, freetype is not threadsafe:
Which I assume translates to |
Just to be clear, the situation causing a segfault is that you're trying to render the text in a different thread than the one you've loaded the font with? I've never tried to use pysdl2 in a multithreaded way before, but if ctypes and/or the underlying libraries themselves don't support this I guess it should be documented clearly somewhere. Generally, pysdl2 has tried to leave as much documentation as possible to the official libsdl.org documentation to avoid issues with duplicating effort and keeping up to date, but this approach also puts us in a bad place when certain functions/behaviours need extra documentation or examples for Python use that the C docs don't cover. I actually have some of the ttf/mixer/image docs ported over to .rst already, so maybe this will be the impetus to finish those up and merge them into master so a proper warning can be added. |
The original issue was that rwops was getting freed while the font was still open, which is different from the other resources in the sdl library family. Sorry I didn't make that clear. |
Ah got it, thanks for the clarification! Have you checked to make sure the "freesrc" argument of the |
Nope, I fixed the issue by keeping the RWops around, and a few other things. |
Ahhhhh, I get it: so SDL2_ttf requires that the RW object you use to create a font is kept in memory for when you try to render some text with that font. You're right, that's pretty odd behaviour and it should probably be documented somewhere by py-sdl2 to avoid future confusion. Thanks for bringing this to our attention! |
In addition, I believe if you free a font after you're released the system (called This doesn't sound like a big deal, and I didn't realize PPB was doing it until I triggered it, but yup. A naive smart pointer wrapping |
I'm getting a segfault when using
TTF_OpenFontRW
withrw_from_object
, but down inTTF_RenderUTF8_Blended
.https://github.com/astronouth7303/pursuedpybear/blob/d2cf78097b29f01f18c6bc948984dc5095de535e/ppb/systems/text.py#L42-L54
https://github.com/astronouth7303/pursuedpybear/blob/d2cf78097b29f01f18c6bc948984dc5095de535e/ppb/systems/text.py#L93-L98
These are running in the context of
concurrent.futures
.I'm getting the backtrace of (from gdb):
Note that frame 0 is from python.
The text was updated successfully, but these errors were encountered: