code changes for SDL3... again

This commit is contained in:
meowtech 2026-03-30 21:01:56 +00:00
parent 41731bc796
commit 8c38116f5b
2 changed files with 12 additions and 12 deletions

View File

@ -31,8 +31,6 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <SDL3_ttf/SDL_ttf.h>
typedef std::pair<std::string, int> FontKey; typedef std::pair<std::string, int> FontKey;
struct FontSet struct FontSet
@ -88,10 +86,10 @@ SharedFontState::~SharedFontState()
delete p; delete p;
} }
void SharedFontState::initFontSetCB(SDL_IOStream &ops, void SharedFontState::initFontSetCB(SDL_IOStream* &ops,
const std::string &filename) const std::string &filename)
{ {
TTF_Font *font = TTF_OpenFontIO(&ops, 0, 0); TTF_Font *font = TTF_OpenFontIO(ops, false, 0);
if (!font) if (!font)
return; return;
@ -109,7 +107,7 @@ void SharedFontState::initFontSetCB(SDL_IOStream &ops,
set.other = filename; set.other = filename;
} }
_TTF_Font *SharedFontState::getFont(std::string family, TTF_Font *SharedFontState::getFont(std::string family,
int size) int size)
{ {
/* Check for substitutions */ /* Check for substitutions */
@ -147,8 +145,8 @@ _TTF_Font *SharedFontState::getFont(std::string family,
? req.regular.c_str() : req.other.c_str(); ? req.regular.c_str() : req.other.c_str();
//ops = SDL_OpenIO(); //ops = SDL_OpenIO();
SDL_IOStream ops; SDL_IOStream* ops;
shState->fileSystem().openReadRaw(*ops, path, true); shState->fileSystem().openReadRaw(ops, path);
} }
font = TTF_OpenFontIO(ops, 1, size); font = TTF_OpenFontIO(ops, 1, size);
@ -157,7 +155,7 @@ _TTF_Font *SharedFontState::getFont(std::string family,
throw Exception(Exception::SDLError, "%s", SDL_GetError()); throw Exception(Exception::SDLError, "%s", SDL_GetError());
p->pool.insert(key, font); p->pool.insert(key, font);
return (_TTF_Font*)font; return font;
} }
bool SharedFontState::fontPresent(std::string family) const bool SharedFontState::fontPresent(std::string family) const
@ -410,7 +408,7 @@ void Font::initDefaults(const SharedFontState &sfs)
FontPrivate::defaultShadow = (rgssVer == 2 ? true : false); FontPrivate::defaultShadow = (rgssVer == 2 ? true : false);
} }
_TTF_Font *Font::getSdlFont() TTF_Font *Font::getSdlFont()
{ {
if (!p->sdlFont) if (!p->sdlFont)
p->sdlFont = shState->fontState().getFont(p->name.c_str(), p->sdlFont = shState->fontState().getFont(p->name.c_str(),

View File

@ -28,6 +28,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <SDL3_ttf/SDL_ttf.h>
struct SDL_IOStream; struct SDL_IOStream;
struct _TTF_Font; struct _TTF_Font;
struct Config; struct Config;
@ -44,10 +46,10 @@ public:
* (when "Fonts/" is scanned for available assets). * (when "Fonts/" is scanned for available assets).
* 'ops' is an opened handle to a possible font file, * 'ops' is an opened handle to a possible font file,
* 'filename' is the corresponding path */ * 'filename' is the corresponding path */
void initFontSetCB(SDL_IOStream &ops, void initFontSetCB(SDL_IOStream* &ops,
const std::string &filename); const std::string &filename);
_TTF_Font *getFont(std::string family, TTF_Font *getFont(std::string family,
int size); int size);
bool fontPresent(std::string family) const; bool fontPresent(std::string family) const;
@ -110,7 +112,7 @@ public:
static void initDefaults(const SharedFontState &sfs); static void initDefaults(const SharedFontState &sfs);
/* internal */ /* internal */
_TTF_Font *getSdlFont(); TTF_Font *getSdlFont();
private: private:
FontPrivate *p; FontPrivate *p;