-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont.cpp
executable file
·50 lines (40 loc) · 1.02 KB
/
font.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "font.h"
#include "configmanager.h"
CFont* CFont::instance = NULL;
CFont::CFont()
{
fontname = L"";
String _fontname = ConfigManager::GetInstance()->GetConfigValue(L"font");
fontname = _fontname;
}
CFont::~CFont()
{
clearFont();
}
void CFont::setFont(String _fontname)
{
if( fontname != L"" )
clearFont();
ConfigManager::GetInstance()->SetConfig(L"font", _fontname);
ConfigManager::GetInstance()->Save();
fontname = _fontname;
}
wxFont *CFont::getFont(int fontsize)
{
wxFont * f = fonts[fontsize];
if (f == NULL)
{
if( fontname == L"" )
fonts[fontsize] = f = new wxFont(fontsize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false);
else
fonts[fontsize] = f = new wxFont(fontsize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, fontname.c_str());
}
return f;
}
void CFont::clearFont()
{
std::map <int, wxFont*>::iterator it;
for(it=fonts.begin(); it!=fonts.end(); it++)
delete (*it).second;
fonts.clear();
}