-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathFont.cpp
More file actions
134 lines (108 loc) · 2.19 KB
/
Copy pathFont.cpp
File metadata and controls
134 lines (108 loc) · 2.19 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Font.cpp: implementation of the Font class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "renlib.h"
#include "Font.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
namespace
{
const int defaultPointSize[] = { 6, 10, 12 };
const bool defaultItalic = false;
const bool defaultBold = false;
const CString defaultFaceName = "System";
}
Font::Font()
{
setDefault(0);
}
Font::~Font()
{
}
void Font::setDefault(int boardSize)
{
mPointSize = defaultPointSize[boardSize];
mIsBold = defaultBold;
mIsItalic = defaultItalic;
mFaceName = defaultFaceName;
}
void Font::getLogFont(LOGFONT& lf)
{
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = mPointSize * 10;
lf.lfWeight = mIsBold ? 700 : 400;
lf.lfItalic = mIsItalic ? TRUE : FALSE;
strcpy (lf.lfFaceName, mFaceName);
}
int Font::getPointSize()
{
return mPointSize;
}
void Font::setPointSize(int pointSize)
{
mPointSize = pointSize;
}
bool Font::isBold()
{
return mIsBold;
}
void Font::setBold(bool bold)
{
mIsBold = bold;
}
bool Font::isItalic()
{
return mIsItalic;
}
void Font::setItalic(bool italic)
{
mIsItalic = italic;
}
CString Font::getFaceName()
{
return mFaceName;
}
void Font::setFaceName(const CString& faceName)
{
mFaceName = faceName;
}
CString Font::toString()
{
CString fontString;
fontString.Format("%d,%d,%d,%s", mPointSize,mIsBold,mIsItalic,mFaceName);
return fontString;
}
void Font::parse(CString fontString, int boardSize)
{
setDefault(boardSize);
char seps[] = ",";
char *token;
token = strtok( fontString.GetBufferSetLength(fontString.GetLength()), seps );
if (token != NULL)
{
mPointSize = atoi(token);
token = strtok( NULL, seps );
}
if (token != NULL)
{
mIsBold = (atoi(token) == 1);
token = strtok( NULL, seps );
}
if (token != NULL)
{
mIsItalic = (atoi(token) == 1);
token = strtok( NULL, seps );
}
if (token != NULL)
{
mFaceName = token;
token = strtok( NULL, seps );
}
}