Skip to content

Commit

Permalink
fix? font.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Speak2Erase committed Aug 15, 2024
1 parent 65fac08 commit fcbe6df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/display/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ SharedFontState::~SharedFontState()
void SharedFontState::initFontSetCB(SDL_IOStream &ops,
const std::string &filename)
{
TTF_Font *font = TTF_OpenFontRW(&ops, 0, 0);
TTF_Font *font = TTF_OpenFontIO(&ops, 0, 0);

if (!font)
return;
Expand All @@ -162,7 +162,7 @@ void SharedFontState::initFontSetCB(SDL_IOStream &ops,
set.other = filename;
}

_TTF_Font *SharedFontState::getFont(std::string family,
TTF_Font *SharedFontState::getFont(std::string family,
int size)
{
std::transform(family.begin(), family.end(), family.begin(),
Expand Down Expand Up @@ -206,14 +206,13 @@ _TTF_Font *SharedFontState::getFont(std::string family,
const char *path = !req.regular.empty()
? req.regular.c_str() : req.other.c_str();

ops = SDL_AllocRW();
shState->fileSystem().openReadRaw(*ops, path, true);
ops = shState->fileSystem().openReadRaw(path, true);
}

// FIXME 0.9 is guesswork at this point
// float gamma = (96.0/45.0)*(5.0/14.0)*(size-5);
// font = TTF_OpenFontRW(ops, 1, gamma /** .90*/);
font = TTF_OpenFontRW(ops, 1, size);
font = TTF_OpenFontIO(ops, 1, size);

if (!font)
throw Exception(Exception::SDLError, "%s", SDL_GetError());
Expand All @@ -237,11 +236,11 @@ bool SharedFontState::fontPresent(std::string family) const
return !(set.regular.empty() && set.other.empty());
}

_TTF_Font *SharedFontState::openBundled(int size)
TTF_Font *SharedFontState::openBundled(int size)
{
SDL_IOStream *ops = openBundledFont();

return TTF_OpenFontRW(ops, 1, size);
return TTF_OpenFontIO(ops, 1, size);
}

void SharedFontState::setDefaultFontFamily(const std::string &family) {
Expand Down Expand Up @@ -511,7 +510,7 @@ void Font::initDefaults(const SharedFontState &sfs)
FontPrivate::defaultShadow = (rgssVer == 2 ? true : false);
}

_TTF_Font *Font::getSdlFont()
TTF_Font *Font::getSdlFont()
{
if (!p->sdlFont)
p->sdlFont = shState->fontState().getFont(p->name.c_str(),
Expand Down
3 changes: 1 addition & 2 deletions src/filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class FileSystem
const char *filename);

/* Circumvents extension supplementing */
void openReadRaw(SDL_IOStream &ops,
const char *filename,
SDL_IOStream* openReadRaw(const char *filename,
bool freeOnClose = false);

std::string normalize(const char *pathname, bool preferred, bool absolute);
Expand Down

0 comments on commit fcbe6df

Please sign in to comment.