我的工作在WinCE的设备,在我试图改变字体类型的GDI的工作,我已经启用的目录项的所有字体类型(宋体,Comic Sans字体MS,快递New,Georgia,Tahoma,Times New Roman,Trebuchet MS,Veradana),我想使用那些字体,但那些不工作,设备只使用默认字体,如何更改WINCE设备字体类型
我使用的代码如下。
void CreateText()
{
// First, clear all fields.
memset (&logfont, 0, sizeof (logfont));
// Create a GDI Times New Roman font.
logfont.lfHeight = 20;
logfont.lfWidth = 0;
logfont.lfEscapement = 0;
logfont.lfOrientation = 0;
logfont.lfWeight = FW_BOLD;
logfont.lfItalic = TRUE;//FALSE;
logfont.lfUnderline = FALSE;
logfont.lfStrikeOut = FALSE;
logfont.lfCharSet = DEFAULT_CHARSET;
logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
_tcsncpy (logfont.lfFaceName, TEXT("Arial"), LF_FACESIZE); //Comic Sans MS
logfont.lfFaceName[LF_FACESIZE-1] = TEXT('\0'); // Ensure null termination
hfontTimes = CreateFontIndirect (&logfont);
//CreatePointFontIndirect(&logfont);
if (!hfontTimes) {
// CreateFontIndirect failed. Insert code here for error
// handling.
printf("\n CreateFontIndirect failed... ");
}
//SendMessage(NULL,WM_SETREDRAW,(WPARAM)TRUE,NULL);
}
void initiateText()
{
// Get a GDI DC onto the backbuffer, where you will render the text.
hdcSurface = GetDC (NULL);
// Select the font into the DC.
hfontSave = (HFONT) SelectObject (hdcSurface, hfontTimes);
// Set the background mode to transparent, so there is no
// rectangle behind the text.
SetBkMode (hdcSurface, TRANSPARENT);
}
void printText (HDC hdcSurface,
int screen_x,
int screen_y,
LPTSTR lpszText,
COLORREF color)
{
int bReturn;
// Set text color.
SetTextColor (hdcSurface, color);
bReturn = ExtTextOut (hdcSurface,
screen_x,
screen_y,
0, // No flags set
NULL, // No clipping rectangle
lpszText, // String to display
lstrlen (lpszText), // Number of characters
NULL); // Use default spacing.
}
如上所述,所选字体不显示在屏幕上,寻找您的建议。
'我想使用的字体,而那些没有工作,设备只能工作与默认字体,'你这个意思是什么?你如何测试?如果您想测试是否添加字体,请打开Word Editor并查看“字体”的下拉菜单。就像这样,只有您已经测试过? – GNKeshava 2013-05-07 06:30:36