summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/sdlfont.cpp14
-rw-r--r--src/gui/sdlfont.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 54dbfbff6..eb05bea8d 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -364,14 +364,13 @@ SDLFont::SDLFont(std::string filename,
++fontCounter;
fixDirSeparators(filename);
- mFont = TTF_OpenFont(resman->getPath(filename).c_str(), size);
+ mFont = openFont(filename.c_str(), size);
if (!mFont)
{
logger->log("Error finding font " + filename);
std::string backFile = "fonts/dejavusans.ttf";
- mFont = TTF_OpenFont(resman->getPath(
- fixDirSeparators(backFile)).c_str(), size);
+ mFont = openFont(fixDirSeparators(backFile).c_str(), size);
if (!mFont)
{
throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " +
@@ -396,6 +395,12 @@ SDLFont::~SDLFont()
}
}
+TTF_Font *SDLFont::openFont(const char *const name, const int size)
+{
+ return TTF_OpenFontIndex(ResourceManager::getInstance()->getPath(
+ name).c_str(), size, 0);
+}
+
void SDLFont::loadFont(std::string filename,
const int size,
const int style)
@@ -410,8 +415,7 @@ void SDLFont::loadFont(std::string filename,
}
fixDirSeparators(filename);
- TTF_Font *const font = TTF_OpenFont(
- resman->getPath(filename).c_str(), size);
+ TTF_Font *const font = openFont(filename.c_str(), size);
if (!font)
{
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h
index 8bab3e3f1..eedc4c6e0 100644
--- a/src/gui/sdlfont.h
+++ b/src/gui/sdlfont.h
@@ -149,6 +149,8 @@ class SDLFont final : public gcn::Font
static bool mSoftMode;
private:
+ static TTF_Font *openFont(const char *const name, const int size);
+
TTF_Font *mFont;
unsigned mCreateCounter;
unsigned mDeleteCounter;