-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText.cpp
More file actions
58 lines (50 loc) · 1.21 KB
/
Text.cpp
File metadata and controls
58 lines (50 loc) · 1.21 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
#include "stdafx.h"
#include "Text.h"
Text::Text()
{
}
Text::~Text()
{
}
void Text::Init()
{
memset(&font, 0, sizeof(font));
strcpy_s(this->text, "basic text");
strcpy_s(this->fontName, "±Ã¼");
this->fontSize = 12;
this->fontWidth = FW_NORMAL;
fontStyle = 0;
characterSet = 0;
SetBkMode(_backBuffer->getMemDC(), 1);
font.lfHeight = fontSize;
font.lfWeight = fontWidth;
strcpy_s(font.lfFaceName, TEXT(fontName));
hFont = CreateFontIndirect(&font);
}
void Text::Init(const char* fontName, int fontSize, const char* text)
{
strcpy_s(this->text, text);
strcpy_s(this->fontName, fontName);
sprintf_s(this->fontPath, "%s.ttf", fontName);
AddFontResourceA(fontPath);
memset(&font, 0, sizeof(font));
this->fontSize = fontSize;
this->fontWidth = FW_NORMAL;
fontStyle = 0;
characterSet = 0;
SetBkMode(_backBuffer->getMemDC(), 1);
font.lfHeight = fontSize;
font.lfWeight = fontWidth;
strcpy_s(font.lfFaceName, TEXT(fontName));
hFont = CreateFontIndirect(&font);
}
void Text::Update()
{
}
void Text::Render()
{
oFont = (HFONT)SelectObject(_backBuffer->getMemDC(), hFont);
TextOut(_backBuffer->getMemDC(), transform->GetX(),
transform->GetY(), text, strlen(text));
SelectObject(_backBuffer->getMemDC(), oFont);
}