Changed m_font map to const fontType map

1008-fix
tomangelo2 2017-10-23 19:08:28 +02:00
parent 1539e94b09
commit 3801ab87a2
2 changed files with 23 additions and 8 deletions

View File

@ -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<std::string>(m_font[type], GetDefaultFont(type));
return std::string("/fonts/") + m_propertyTree.get<std::string>(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);
}

View File

@ -49,6 +49,16 @@ const std::map<Gfx::FontType, std::string> defaultFont =
{ Gfx::FONT_SATCOM, "dvu_sans.ttf" },
};
const std::map<Gfx::FontType, std::string> 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<Gfx::FontType, std::string> m_font;
};