Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Construct Font Families and Fonts

GDI+ groups fonts with the same typeface but different styles into font families. For example, the Arial font family contains the following fonts:

  • Arial Regular

  • Arial Bold

  • Arial Italic

  • Arial Bold Italic

GDI+ uses four styles to form families: regular, bold, italic, and bold italic. Adjectives such as narrow and rounded are not considered styles; rather they are part of the family name. For example, Arial Narrow is a font family with the following members:

  • Arial Narrow Regular

  • Arial Narrow Bold

  • Arial Narrow Italic

  • Arial Narrow Bold Italic

Before you can draw text with GDI+, you need to construct a FontFamily object and a Font object. The FontFamily object specifies the typeface (for example, Arial), and the Font object specifies the size, style, and units.

The following example constructs a regular style Arial font with a size of 16 pixels. In the following code, the first argument passed to the Font constructor is the FontFamily object. The second argument specifies the size of the font measured in units identified by the fourth argument. The third argument identifies the style.

Pixel is a member of the GraphicsUnit enumeration, and Regular is a member of the FontStyle enumeration.

FontFamily fontFamily = new FontFamily("Arial");
Font font = new Font(

The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of PaintEventHandler.

Community Additions

© 2015 Microsoft