diff --git a/src/common/font_config.cpp b/src/common/font_config.cpp index 3d3ad6f0..8dd59eaa 100644 --- a/src/common/font_config.cpp +++ b/src/common/font_config.cpp @@ -42,12 +42,6 @@ CFontConfig::CFontConfig() : m_needsSave(false) , m_loaded(false) { - m_font[Gfx::FONT_COMMON] = "FontCommon"; - m_font[Gfx::FONT_COMMON_BOLD] = "FontCommonBold"; - m_font[Gfx::FONT_COMMON_ITALIC] = "FontCommonItalic"; - m_font[Gfx::FONT_STUDIO] = "FontStudio"; - m_font[Gfx::FONT_STUDIO_BOLD] = "FontStudioBold"; - m_font[Gfx::FONT_SATCOM] = "FontSatCom"; } CFontConfig::~CFontConfig() @@ -85,10 +79,15 @@ bool CFontConfig::Init() std::string CFontConfig::GetFont(Gfx::FontType type) { - return std::string("/fonts/") + m_propertyTree.get(m_font[type], GetDefaultFont(type)); + return std::string("/fonts/") + m_propertyTree.get(GetFontType(type), GetDefaultFont(type)); } std::string CFontConfig::GetDefaultFont(Gfx::FontType type) const { return defaultFont.at(type); +} + +std::string CFontConfig::GetFontType(Gfx::FontType type) const +{ + return fontType.at(type); } \ No newline at end of file diff --git a/src/common/font_config.h b/src/common/font_config.h index 5ce91aaf..a91e5fa0 100644 --- a/src/common/font_config.h +++ b/src/common/font_config.h @@ -49,6 +49,16 @@ const std::map defaultFont = { Gfx::FONT_SATCOM, "dvu_sans.ttf" }, }; +const std::map fontType = +{ + { Gfx::FONT_COMMON, "FontCommon" }, + { Gfx::FONT_COMMON_BOLD, "FontCommonBold" }, + { Gfx::FONT_COMMON_ITALIC, "FontCommonItalic" }, + { Gfx::FONT_STUDIO, "FontStudio" }, + { Gfx::FONT_STUDIO_BOLD, "FontStudioBold" }, + { Gfx::FONT_SATCOM, "FontSatCom" }, +}; + class CFontConfig { public: @@ -70,9 +80,15 @@ public: * \return return filename of default path */ std::string GetDefaultFont(Gfx::FontType type) const; + + /** Const type method converting Gfx::FontType to string + * \return return id of font used in fonts.ini file + */ + + std::string GetFontType(Gfx::FontType type) const; + private: boost::property_tree::ptree m_propertyTree; bool m_needsSave; bool m_loaded; - std::map m_font; };