Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
Font.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <string>
4
//#include <d3dx10.h>
5
6
class
Font
7
{
8
Logger
*
logger
;
9
std::string
pathAndFilename
;
10
11
public
:
12
//ID3DX10Font* pFont = nullptr;
13
Rendering::RenderFont
*
pFont
=
nullptr
;
14
15
//Font(Logger* pLogger, ID3D10Device* pDevice, float width, float height, std::string name, std::string prmPathAndFilename)
16
Font
(
Logger
* pLogger,
Rendering::RenderDevice
* pDevice,
int
width,
int
height, std::string name, std::string prmPathAndFilename)
17
{
18
logger
= pLogger;
19
20
logger
->
AddToCallStack
(
"Font::ctor"
);
21
pathAndFilename
= prmPathAndFilename;
22
23
char
err[256];
24
sprintf_s(err, 256,
"Font::ctor AddFontResourceExA: %s"
,
pathAndFilename
.c_str());
25
logger
->
Log
(err);
26
27
const
int
fontsAdded = AddFontResourceExA(
pathAndFilename
.c_str(), FR_PRIVATE,
nullptr
);
28
if
(fontsAdded == 0)
29
{
30
sprintf_s(err, 256,
"Font::ctor AddFontResourceExA: %s"
,
pathAndFilename
.c_str());
31
logger
->
Log
(err,
Logger::Warn
);
32
}
33
34
HRESULT
hr;
35
if
(FAILED(hr =
Rendering::CreateFontA
(pDevice, height, width, FW_MEDIUM, 1,
false
, DEFAULT_CHARSET,
36
OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
37
name.c_str(), &
pFont
)))
38
{
39
sprintf_s(err, 256,
"Font::ctor Rendering::CreateFontA failed: %s"
, name.c_str());
40
logger
->
Log
(err,
Logger::Error
, hr);
41
}
42
}
43
44
void
Font::OnDestroyDevice
()
45
{
46
logger
->
AddToCallStack
(
"Font::OnDestroyDevice"
);
47
// @todo this one gets called correctly before the references are counted but should not be handled in DTOR
48
SAFE_RELEASE
(
pFont
);
49
logger
->
AddToCallStack
(
"Font::OnDestroyDevice RemoveFontResourceExA"
);
50
RemoveFontResourceExA(
pathAndFilename
.c_str(), FR_PRIVATE,
nullptr
);
51
logger
->
AddToCallStack
(
"Font::OnDestroyDevice DONE"
);
52
}
53
};
SAFE_RELEASE
#define SAFE_RELEASE(value)
Definition
ClientRuntime11.h:32
HRESULT
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Font::Font
Font(Logger *pLogger, Rendering::RenderDevice *pDevice, int width, int height, std::string name, std::string prmPathAndFilename)
Definition
Font.h:16
Font::pFont
Rendering::RenderFont * pFont
Definition
Font.h:13
Font::OnDestroyDevice
void OnDestroyDevice()
Definition
Font.h:44
Font::logger
Logger * logger
Definition
Font.h:8
Font::pathAndFilename
std::string pathAndFilename
Definition
Font.h:9
Logger
Definition
Logger.h:11
Logger::Log
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition
Logger.cpp:283
Logger::AddToCallStack
void AddToCallStack(const char *msg)
Definition
Logger.cpp:355
Logger::Warn
@ Warn
Definition
Logger.h:26
Logger::Error
@ Error
Definition
Logger.h:28
Rendering::RenderDevice
Definition
ClientRenderer11.h:92
Rendering::RenderFont
Definition
ClientRenderer11.h:222
Rendering::CreateFontA
HRESULT CreateFontA(RenderDevice *owner, INT height, UINT width, UINT weight, UINT mipLevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitch, const char *face, RenderFont **result)
Definition
ClientResources11.cpp:290
Displays
Font.h
Generated on
for Rise by
1.18.0