-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCFont.cpp
More file actions
executable file
·102 lines (77 loc) · 2.54 KB
/
CFont.cpp
File metadata and controls
executable file
·102 lines (77 loc) · 2.54 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
#include "CFont.h"
CFont::CFont()
{
}
CFont::CFont(LPDIRECT3DDEVICE9 pD3DDevice, LPCTSTR pFontFace, int nHeight, bool fBold, bool fItalic, bool fUnderlined)
{
//HFONT hFont;
m_pD3DDevice = pD3DDevice;
fontSize = nHeight;
bold = fBold;
italisized = fItalic;
fontType = pFontFace;
int nWeight = FW_NORMAL;
if(bold)
{
nWeight = FW_BOLD;
}
//hFont = CreateFont(nHeight, 0, 0, 0, nWeight, dwItalic, dwUnderlined, 0, ANSI_CHARSET, 0, 0, 0, 0, pFontFace);
D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
fontType, &m_pFont );
//D3DXCreateFont(m_pD3DDevice, hFont, &m_pFont);
}
CFont::~CFont()
{
//release();
}
void CFont::setFontType(LPCTSTR newFontType)
{
fontType = newFontType;
//re-initialise the font object
D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
fontType, &m_pFont );
}
void CFont::setFontSize(int newFontSize)
{
fontSize = newFontSize;
//re-initialise the font object
D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
fontType, &m_pFont );
}
void CFont::setBold(bool newValue)
{
bold = newValue;
//re-initialise the font object
D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
fontType, &m_pFont );
}
void CFont::setItalics(bool newValue)
{
italisized = newValue;
//re-initialise the font object
D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
fontType, &m_pFont );
}
void CFont::DrawText(LPCTSTR pText, int x, int y, D3DCOLOR rgbFontColour)
{
//re-initialise the font object
// D3DXCreateFont( m_pD3DDevice, fontSize, 0, FW_BOLD, 0, italisized, DEFAULT_CHARSET,
// OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
// fontType, &m_pFont );
RECT Rect = {x,y,0,0};
m_pFont->DrawText(NULL, pText, -1, &Rect, DT_CALCRECT, 0);
m_pFont->DrawText(NULL, pText, -1, &Rect, 0, rgbFontColour);
//clear font object
// release();
}
void CFont::release()
{
m_pFont->OnLostDevice();
m_pFont->Release();
//SAFE_RELEASE(m_pFont);
}