我的工作在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