CFont font; font.CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); LOGFONT lf; font.GetLogFont(&lf);
CFont font; font.CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); HFONT hFont = (HFONT)font.GetSafeHandle();In this example, a font object is created using the CreateFont function. The GetSafeHandle function is then called to retrieve the font handle. Package library: MFC (Microsoft Foundation Classes) library.