| Summary: | TTF_OpenFontRW( ... ) fails on Windows while working on Linux. | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Klaus Blindert <klaus.blindert> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | mikael_miffe_eriksson |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
When creating the RWops, you have to specifiy the mode as "rb", not just "r". This is also safe on linux. Good point, thanks Mikael! Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL. --ryan. |
First: Thanks for this nice library. We are going to use it in our game engine: www.fifengine.de But now to the bug(s). This is perfectly valid code on Linux. But on Windows it throughs the second exception, when the font file exists. SDL_RWops* rwops = SDL_RWFromFile(filename.c_str(),"r"); if( rwops ) { mFont = TTF_OpenFontRW(rwops,1,size); } else { throw GCN_EXCEPTION("Error loading file:"+filename + " SDL_Error: "+std::string(SDL_GetError())); }; if (mFont == NULL) { throw GCN_EXCEPTION("Error loading file: "+filename + " TTF_Error: "+std::string(TTF_GetError())); } We introduced RWops, for the following reason: The following snippet works on windows and linux, but SEGFAULTS when the file is nonexistent. This can be worked around, but is still a bug. mFont = TTF_OpenFont(filename.c_str(),size); if (mFont == NULL) { throw GCN_EXCEPTION("Error loading file: "+filename + " TTF_Error: "+std::string(TTF_GetError())); } Since we use a virtual filesystem, it would be good, if SDL_TTF works with RWops together. I didn't find anything related. It's too late today to dive into the TTF sourcecode, but I will assist in figuring the problem out. I think, we'll be able to work around the bug ... Library version is 2.0.7 Greetings, Klaus (aka Phoku)