Rise
The Vieneo Province
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
6class Font
7{
9 std::string pathAndFilename;
10
11public:
12 //ID3DX10Font* 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
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
49 logger->AddToCallStack("Font::OnDestroyDevice RemoveFontResourceExA");
50 RemoveFontResourceExA(pathAndFilename.c_str(), FR_PRIVATE, nullptr);
51 logger->AddToCallStack("Font::OnDestroyDevice DONE");
52 }
53};
#define SAFE_RELEASE(value)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Font(Logger *pLogger, Rendering::RenderDevice *pDevice, int width, int height, std::string name, std::string prmPathAndFilename)
Definition Font.h:16
Rendering::RenderFont * pFont
Definition Font.h:13
void OnDestroyDevice()
Definition Font.h:44
Logger * logger
Definition Font.h:8
std::string pathAndFilename
Definition Font.h:9
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
@ Warn
Definition Logger.h:26
@ Error
Definition Logger.h:28
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)