diff options
Diffstat (limited to 'src/graphics/engine/text.cpp')
-rw-r--r-- | src/graphics/engine/text.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index ea7fd14..bebf30c 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -21,11 +21,11 @@ #include "graphics/engine/text.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/image.h" #include "common/logger.h" #include "common/stringutils.h" +#include "common/resources/resourcemanager.h" #include "math/func.h" @@ -80,12 +80,12 @@ bool CText::Create() return false; } - m_fonts[FONT_COLOBOT] = new MultisizeFont("dvu_sans.ttf"); - m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("dvu_sans_bold.ttf"); - m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("dvu_sans_italic.ttf"); + m_fonts[FONT_COLOBOT] = new MultisizeFont("fonts/dvu_sans.ttf"); + m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("fonts/dvu_sans_bold.ttf"); + m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("fonts/dvu_sans_italic.ttf"); - m_fonts[FONT_COURIER] = new MultisizeFont("dvu_sans_mono.ttf"); - m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("dvu_sans_mono_bold.ttf"); + m_fonts[FONT_COURIER] = new MultisizeFont("fonts/dvu_sans_mono.ttf"); + m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("fonts/dvu_sans_mono_bold.ttf"); for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it) { @@ -868,10 +868,14 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size) return m_lastCachedFont; } - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName); - m_lastCachedFont = new CachedFont(); - m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize); + SDL_RWops* file = CResourceManager::GetSDLFileHandler(mf->fileName); + if(file == nullptr) + { + m_error = std::string("Unable to open file"); + return nullptr; + } + m_lastCachedFont->font = TTF_OpenFontRW(file, 1, pointSize); if (m_lastCachedFont->font == nullptr) m_error = std::string("TTF_OpenFont error ") + std::string(TTF_GetError()); |