CFont Class |
Description
The class responsible for creating and managing font resources.
CFont Members
Initialization and Assignment | |
CFont | CFont(); CFont(HFONT hFont); CFont(const LOGFONT* lpLogFont);Constructs a CFont object. |
static CFont* FromHandle(HFONT hFont);Returns the CFont associated with the specified font handle. If a CFont object doesn't already exist, a temporary CFont object is created. This temporary CFont will be deleted sometime after the processing of the current message is complete.
operator HFONT() const;Allows a CFont object to be used as a font handle (HFONT).
LOGFONT GetLogFont() const;Retrieves the LOGFONT structure that contains font attributes.
HFONT CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, DWORD dwItalic, DWORD dwUnderline, DWORD dwStrikeOut, DWORD dwCharSet, DWORD dwOutPrecision, DWORD dwClipPrecision, DWORD dwQuality, DWORD dwPitchAndFamily, LPCTSTR lpszFacename);Creates a logical font with the specified characteristics.
HFONT CreateFontIndirect(const LOGFONT* lpLogFont);Creates a logical font that has the characteristics specified in the LOGFONT struct.
HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL, BOOL bBold = FALSE, BOOL bItalic = FALSE);Creates a font of a specified typeface and point size.
HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC = NULL);Creates a font of a specified typeface and point size. This function automatically converts the height in the LOGFONT's lfHeight to logical units using the specified device context.
Base class Members
For base class members, refer to the members of CGDIObject.
Remarks
CFont objects can be used anywhere a a handle to a font (HFONT) might be used. They can be substituted for the HFONT in any of the Windows API functions which use a HFONT as a function argument. The benefit of using a CFont object is that it automatically deletes the font when it is destroyed.
Refer to the Graphics Device Interface section of Using Win32++ for additional information on using this class.
Summary Information
Header file | gdi.h |
Win32/64 support | Yes |
WinCE support | Yes |