summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-20 20:04:28 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-21 01:19:25 +0300
commit46f7f1bfd524f95dcff7d422d591c9c43f542834 (patch)
treeea2ffb19488c90758ada713fe1bf1ee457110b60 /src/gui
parent9dc3d09dd336f46ce988a41eeaed4c7f229d25cc (diff)
downloadmanaverse-46f7f1bfd524f95dcff7d422d591c9c43f542834.tar.gz
manaverse-46f7f1bfd524f95dcff7d422d591c9c43f542834.tar.bz2
manaverse-46f7f1bfd524f95dcff7d422d591c9c43f542834.tar.xz
manaverse-46f7f1bfd524f95dcff7d422d591c9c43f542834.zip
In SDL2 builds at first try load fonts from virtfs.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/fonts/font.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
index 70adce617..173a188c2 100644
--- a/src/gui/fonts/font.cpp
+++ b/src/gui/fonts/font.cpp
@@ -70,6 +70,9 @@
#include "fs/paths.h"
#include "fs/virtfs/tools.h"
+#ifdef USE_SDL2
+#include "fs/virtfs/rwops.h"
+#endif // USE_SDL2
#include "gui/fonts/textchunk.h"
@@ -187,13 +190,20 @@ Font::~Font()
TTF_Font *Font::openFont(const char *const name,
const int size)
{
-// disabled for now because some systems can't use it. why?
-// #ifdef USE_SDL2
-// SDL_RWops *const rw = VirtFs::rwopsOpenRead(name);
-// if (!rw)
-// return nullptr;
-// return TTF_OpenFontIndexRW(rw, 1, size, 0);
-// #else
+#ifdef USE_SDL2
+ SDL_RWops *const rw = VirtFs::rwopsOpenRead(name);
+ if (rw)
+ {
+ logger->log("Loading virtfs font file: %s",
+ name);
+ return TTF_OpenFontIndexRW(rw, 1, size, 0);
+ }
+ else
+ {
+ reportAlways("Error: Loading virtfs font file: %s",
+ name);
+ }
+#endif
const std::string path = VirtFs::getPath(name);
if (Files::existsLocal(path) == false)
{
@@ -208,7 +218,6 @@ TTF_Font *Font::openFont(const char *const name,
path.c_str());
return TTF_OpenFontIndex(path.c_str(),
size, 0);
-// #endif
}
void Font::loadFont(std::string filename,