From 46f7f1bfd524f95dcff7d422d591c9c43f542834 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 20 May 2017 20:04:28 +0300 Subject: In SDL2 builds at first try load fonts from virtfs. --- src/gui/fonts/font.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/gui/fonts') 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, -- cgit v1.2.3-60-g2f50