|
|
我写了个D3D的程序,里面是这样设置字体的
CFont::CFont(LPDIRECT3DDEVICE8 dp,LPSTR font,int nHeight,bool fBold, bool fItalic, bool fUnderlined)
{
HFONT hFont;
m_pD3DDevice = dp;
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, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, font);
D3DXCreateFont(m_pD3DDevice, hFont, &m_pFont);
}
void CFont: rawText(LPSTR txt, 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(txt, -1, &Rect, DT_CALCRECT, 0); //Calculate the size of the
//rect needed
m_pFont->DrawTextA(txt, -1, &Rect, DT_LEFT, rgbFontColour); //Draw the text
m_pFont->End();
}
主函数里面是这样的创建字体的
font = new CFont(m_pD3DDevice,"华文新魏",50,false,false,false);
但是问题是不管我怎么设置字体,都是系统默认字体,哪位有经验的大虾能告诉我啊,谢谢了!
|
|