Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Font class

Applies to: desktop apps only

The Font class encapsulates the characteristics, such as family, height, size, and style (or combination of styles), of a specific font. A Font object is used when drawing strings.

Members

The Font class inherits from GdiplusBase. Font also has these types of members:

Constructors

The Font class has these constructors.

ConstructorDescription
Font::Font(FontFamily*,REAL,INT,Unit)

Creates a Font::Font object based on a FontFamily object, a size, a font style, and a unit of measurement.

Font::Font(HDC)

Creates a Font::Font object based on the GDI font object that is currently selected into a specified device context. This constructor is provided for compatibility with GDI.

Font::Font(HDC,HFONT)

Creates a Font::Font object indirectly from a GDI logical font by using a handle to a GDI LOGFONT structure.

Font::Font(HDC,LOGFONTA*)

Creates a Font::Font object directly from a GDI logical font. The GDI logical font is a LOGFONTA structure, which is the one-byte character version of a logical font. This constructor is provided for compatibility with GDI.

Font::Font(HDC,LOGFONTW*)

Creates a Font::Font object directly from a GDI logical font. The GDI logical font is a LOGFONTW structure, which is the wide character version of a logical font. This constructor is provided for compatibility with GDI.

Font::Font(WCHAR*,REAL,INT,Unit,FontCollection*)

Creates a Font::Font object based on a font family, a size, a font style, a unit of measurement, and a FontCollection object.

 

Methods

The Font class has these methods.

MethodDescription
Font::Clone

The Font::Clone method creates a new Font object based on this Font object.

Font::GetFamily

The Font::GetFamily method gets the font family on which this font is based.

Font::GetHeight(Graphics*)

The Font::GetHeight method gets the line spacing of this font in the current unit of a specified Graphics object. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.

Font::GetHeight(REAL)

The Font::GetHeight method gets the line spacing, in pixels, of this font. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.

Font::GetLastStatus

The Font::GetLastStatus method returns a value that indicates the nature of this Font object's most recent method failure.

Font::GetLogFontA

The Font::GetLogFontA method uses a LOGFONTA structure to get the attributes of this Font object.

Font::GetLogFontW

The Font::GetLogFontW method uses a LOGFONTW structure to get the attributes of this Font object.

Font::GetSize

The Font::GetSize method returns the font size (commonly called the em size) of this Font object. The size is in the units of this Font object.

Font::GetStyle

The Font::GetStyle method gets the style of this font's typeface.

Font::GetUnit

The Font::GetUnit method returns the unit of measure of this Font object.

Font::IsAvailable

The Font::IsAvailable method determines whether this Font object was created successfully.

 

Remarks

When using GDI+ API, you must never allow your application to download arbitrary fonts from untrusted sources. The operating system requires elevated privileges to assure that all installed fonts are trusted.

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show:
© 2014 Microsoft