1 #pragma once
2 #ifndef	_FONTDD_H_
3 #define	_FONTDD_H_
4 
5 #include	"base.h"
6 #include	"SmartPtr.h"
7 #include	"Font.h"
8 #include	<tchar.h>
9 
10 namespace	DisplayOutput
11 {
12 
13 /*
14 	CFontDX.
15 
16 */
17 class	CFontDD :	public CBaseFont
18 {
19 	HFONT	m_pDDFont;
20 
21 	public:
CFontDD()22 			CFontDD( )
23 			{
24 				m_pDDFont = NULL;
25 			}
~CFontDD()26 			virtual ~CFontDD()
27 			{
28 				if (m_pDDFont != NULL)
29 				{
30 					DeleteObject(m_pDDFont);
31 					m_pDDFont = NULL;
32 				}
33 			}
34 
Create()35 			bool	Create()
36 			{
37 				LOGFONTA logfont = {0};
38 				switch ( m_FontDescription.Style() )
39 				{
40 					case CFontDescription::Thin:		logfont.lfWeight |= FW_THIN;		break;
41 					case CFontDescription::Light:		logfont.lfWeight |= FW_LIGHT;		break;
42 					case CFontDescription::Normal:		logfont.lfWeight |= FW_NORMAL;		break;
43 					case CFontDescription::Bold:		logfont.lfWeight |= FW_BOLD;		break;
44 					case CFontDescription::UberBold:	logfont.lfWeight |= FW_EXTRABOLD;	break;
45 				}
46 				logfont.lfHeight = m_FontDescription.Height();
47 				//HDC hdc = GetDC(NULL);
48 				//if (hdc != NULL)
49 				//{
50 				//	logfont.lfHeight = -MulDiv(m_FontDescription.Height(), GetDeviceCaps(hdc ,LOGPIXELSY), 72);
51 				//	ReleaseDC(NULL, hdc);
52 				//	logfont.lfHeight = -MulDiv(m_FontDescription.Height(), 72, 72) - 1;
53 				//}
54 				//else
55 				//{
56 				//	logfont.lfHeight = -MulDiv(m_FontDescription.Height(), 72, 72) - 1;
57 				//}
58 				logfont.lfItalic = m_FontDescription.Italic();
59 				logfont.lfQuality = m_FontDescription.AntiAliased() ? ANTIALIASED_QUALITY : NONANTIALIASED_QUALITY;
60 				strcpy_s(logfont.lfFaceName, 32, m_FontDescription.TypeFace().c_str());
61 
62 				m_pDDFont = CreateFontIndirectA(&logfont);
63 
64 				return true;
65 			}
66 
GetDDFont(void)67 			HFONT	GetDDFont( void )	{	return(	m_pDDFont );	};
68 };
69 
70 MakeSmartPointers( CFontDD );
71 
72 };
73 
74 #endif
75