diff --git a/data/stk_config.xml b/data/stk_config.xml index 2d39f3207..a36995311 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -749,4 +749,21 @@ + + + + diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 8d1a891ba..58650278e 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -385,6 +385,17 @@ void STKConfig::getAllData(const XMLNode * root) } + if(const XMLNode *font_node = root->getNode("font")) + { + font_node->get("default", &m_font_default ); + font_node->get("default_fallback", &m_font_default_fallback); + font_node->get("cjk", &m_font_cjk ); + font_node->get("ar", &m_font_ar ); + font_node->get("bold", &m_font_bold ); + font_node->get("bold_fallback", &m_font_bold_fallback ); + font_node->get("digit", &m_font_digit ); + } + // Get the default KartProperties // ------------------------------ const XMLNode *node = root -> getNode("general-kart-defaults"); diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index 35f57c89a..62da73c98 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -160,6 +160,15 @@ public: /** The field of view for 1, 2, 3, 4 player split screen. */ float m_camera_fov[4]; + /** File names of the default fonts in STK. */ + std::string m_font_default; + std::string m_font_default_fallback; + std::string m_font_cjk; + std::string m_font_ar; + std::string m_font_bold; + std::string m_font_bold_fallback; + std::string m_font_digit; + private: /** True if stk_config has been loaded. This is necessary if the * --stk-config command line parameter has been specified to avoid diff --git a/src/guiengine/ft_environment.cpp b/src/guiengine/ft_environment.cpp index 6e90e424b..eb83dec25 100644 --- a/src/guiengine/ft_environment.cpp +++ b/src/guiengine/ft_environment.cpp @@ -19,6 +19,7 @@ #include "guiengine/ft_environment.hpp" #include "io/file_manager.hpp" #include "utils/log.hpp" +#include "config/stk_config.hpp" #include @@ -70,31 +71,31 @@ void FTEnvironment::checkError(FT_Error err, const irr::core::stringc desc) void FTEnvironment::loadFont() { checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "Ubuntu-R.ttf", true)).c_str(), + (FileManager::TTF, stk_config->m_font_default.c_str(), true)).c_str(), 0, &m_ft_face[F_DEFAULT]), "loading F_DEFAULT"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "FreeSans.ttf",true)).c_str(), + (FileManager::TTF, stk_config->m_font_default_fallback.c_str(), true)).c_str(), 0, &m_ft_face[F_DEFAULT_FALLBACK]), "loading F_DEFAULT_FALLBACK"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "wqy-microhei.ttf",true)).c_str(), + (FileManager::TTF, stk_config->m_font_cjk.c_str(), true)).c_str(), 0, &m_ft_face[F_CJK]), "loading F_CJK"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "NotoNaskhArabicUI-Bold.ttf",true)).c_str(), + (FileManager::TTF, stk_config->m_font_ar.c_str(), true)).c_str(), 0, &m_ft_face[F_AR]), "loading F_AR"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "Ubuntu-B.ttf", true)).c_str(), + (FileManager::TTF, stk_config->m_font_bold.c_str(), true)).c_str(), 0, &m_ft_face[F_BOLD]), "loading F_BOLD"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "FreeSansBold.ttf", true)).c_str(), + (FileManager::TTF, stk_config->m_font_bold_fallback.c_str(), true)).c_str(), 0, &m_ft_face[F_BOLD_FALLBACK]), "loading F_BOLD_FALLBACK"); checkError(FT_New_Face(m_ft_lib, (file_manager->getAssetChecked - (FileManager::TTF, "SigmarOne.otf",true)).c_str(), + (FileManager::TTF, stk_config->m_font_digit.c_str(),true)).c_str(), 0, &m_ft_face[F_DIGIT]), "loading F_DIGIT"); //Set charmap diff --git a/src/guiengine/scalable_font.cpp b/src/guiengine/scalable_font.cpp index d0a638445..f7f1f7beb 100644 --- a/src/guiengine/scalable_font.cpp +++ b/src/guiengine/scalable_font.cpp @@ -23,11 +23,6 @@ #include "io/file_manager.hpp" #include "utils/translation.hpp" -#include -#include -#include -#include - #include #include #include @@ -310,7 +305,7 @@ bool ScalableFont::loadTTF() m_glyph_max_height = curr_maxheight; - for(wchar_t c='0'; c<='9'; c++) + for(wchar_t c = '0'; c <= '9'; c++) { SFontArea a = getAreaFromCharacter(c, NULL); m_max_digit_area.width = a.width; @@ -815,7 +810,7 @@ void ScalableFont::doDraw(const core::stringw& text, if (m_type == T_NORMAL || T_BOLD) //lazy load char, have to do this again { //because some text isn't drawn with getDimension - for (u32 i = 0; i #include #include