Changed defaultFont to const map
parent
76a8335501
commit
1539e94b09
|
@ -42,14 +42,6 @@ CFontConfig::CFontConfig()
|
|||
: m_needsSave(false)
|
||||
, m_loaded(false)
|
||||
{
|
||||
//default fonts
|
||||
m_defaultFont[Gfx::FONT_COMMON] = "/fonts/dvu_sans.ttf";
|
||||
m_defaultFont[Gfx::FONT_COMMON_BOLD] = "/fonts/dvu_sans_bold.ttf";
|
||||
m_defaultFont[Gfx::FONT_COMMON_ITALIC] = "/fonts/dvu_sans_italic.ttf";
|
||||
m_defaultFont[Gfx::FONT_STUDIO] = "/fonts/dvu_sans_mono.ttf";
|
||||
m_defaultFont[Gfx::FONT_STUDIO_BOLD] = "/fonts/dvu_sans_mono_bold.ttf";
|
||||
m_defaultFont[Gfx::FONT_SATCOM] = "/fonts/dvu_sans.ttf";
|
||||
|
||||
m_font[Gfx::FONT_COMMON] = "FontCommon";
|
||||
m_font[Gfx::FONT_COMMON_BOLD] = "FontCommonBold";
|
||||
m_font[Gfx::FONT_COMMON_ITALIC] = "FontCommonItalic";
|
||||
|
@ -93,14 +85,10 @@ bool CFontConfig::Init()
|
|||
|
||||
std::string CFontConfig::GetFont(Gfx::FontType type)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string path = std::string("/fonts/") + m_propertyTree.get<std::string>(m_font[type]);
|
||||
return path;
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return m_defaultFont[type];
|
||||
}
|
||||
return std::string("/fonts/") + m_propertyTree.get<std::string>(m_font[type], GetDefaultFont(type));
|
||||
}
|
||||
|
||||
std::string CFontConfig::GetDefaultFont(Gfx::FontType type) const
|
||||
{
|
||||
return defaultFont.at(type);
|
||||
}
|
|
@ -39,6 +39,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
const std::map<Gfx::FontType, std::string> defaultFont =
|
||||
{
|
||||
{ Gfx::FONT_COMMON, "dvu_sans.ttf" },
|
||||
{ Gfx::FONT_COMMON_BOLD, "dvu_sans_bold.ttf" },
|
||||
{ Gfx::FONT_COMMON_ITALIC, "dvu_sans_italic.ttf" },
|
||||
{ Gfx::FONT_STUDIO, "dvu_sans_mono.ttf" },
|
||||
{ Gfx::FONT_STUDIO_BOLD, "dvu_sans_mono_bold.ttf" },
|
||||
{ Gfx::FONT_SATCOM, "dvu_sans.ttf" },
|
||||
};
|
||||
|
||||
class CFontConfig
|
||||
{
|
||||
public:
|
||||
|
@ -55,9 +65,14 @@ public:
|
|||
*/
|
||||
std::string GetFont(Gfx::FontType type);
|
||||
|
||||
/** Const type method to read filenames of fonts from defaultFont map
|
||||
* used as a fallback if it wasn't possible to read font from fonts.ini
|
||||
* \return return filename of default path
|
||||
*/
|
||||
std::string GetDefaultFont(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, m_defaultFont;
|
||||
std::map<Gfx::FontType, std::string> m_font;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue