📄 font.cpp
字号:
#include "Font.h"
CFont::CFont(LPDIRECT3DDEVICE8 pD3DDevice,LPSTR pFontFace,
int nHeight,bool fBold,bool fItalic,bool fUnderlined)
{
HFONT hFont;
m_pD3DDevice=pD3DDevice;
int nWeight=FW_NORMAL;
DWORD dwItalic=0;
DWORD dwUnderlined=0;
if(fBold)
nWeight=FW_BOLD;
if(fItalic)
dwItalic=1;
if(fUnderlined)
dwUnderlined=1;
hFont=CreateFont(nHeight,0,0,0,nWeight,dwItalic,dwUnderlined,
0,ANSI_CHARSET,0,0,0,0,pFontFace);
D3DXCreateFont(m_pD3DDevice,hFont,&m_pFont);
LogInfo("<li>Font loaded OK");
}
CFont::~CFont()
{
SafeRelease(m_pFont);
LogInfo("<li>Font destroyed OK");
}
void CFont::DrawText(LPSTR pText,int x,int y,D3DCOLOR rgbFontColour)
{
RECT Rect;
Rect.left=x;
Rect.top=y;
Rect.right=0;
Rect.bottom=0;
m_pFont->Begin();
m_pFont->DrawTextA(pText,-1,&Rect,DT_CALCRECT,0);
m_pFont->DrawTextA(pText,-1,&Rect,DT_LEFT,rgbFontColour);
m_pFont->End();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -