共用方式為


CFont Class

Encapsulates a Windows graphics device interface (GDI) font and provides member functions for manipulating the font.

class CFont : public CGdiObject

Members

Public Constructors

Name

Description

CFont::CFont

Constructs a CFont object.

Public Methods

Name

Description

CFont::CreateFont

Initializes a CFont with the specified characteristics.

CFont::CreateFontIndirect

Initializes a CFont object with the characteristics given in a LOGFONT structure.

CFont::CreatePointFont

Initializes a CFont with the specified height, measured in tenths of a point, and typeface.

CFont::CreatePointFontIndirect

Same as CreateFontIndirect except that the font height is measured in tenths of a point rather than logical units.

CFont::FromHandle

Returns a pointer to a CFont object when given a Windows HFONT.

CFont::GetLogFont

Fills a LOGFONT with information about the logical font attached to the CFont object.

Public Operators

Name

Description

CFont::operator HFONT

Returns the Windows GDI font handle attached to the CFont object.

Remarks

To use a CFont object, construct a CFont object and attach a Windows font to it with CreateFont, CreateFontIndirect, CreatePointFont, or CreatePointFontIndirect, and then use the object's member functions to manipulate the font.

The CreatePointFont and CreatePointFontIndirect functions are often easier to use than CreateFont or CreateFontIndirect since they do the conversion for the height of the font from a point size to logical units automatically.

For more information on CFont, see Graphic Objects.

Inheritance Hierarchy

CObject

CGdiObject

CFont

Requirements

Header: afxwin.h

See Also

Reference

CGdiObject Class

Hierarchy Chart

Concepts

MFC Sample HIERSVR