Using Fonts and Text

 

There are several classes offered by GDI+ and GDI for drawing text on Windows Forms. The GDI+ Graphics class has several DrawString methods that allow you to specify various features of text, such as location, bounding rectangle, font, and format. In addition, you can draw and measure text with GDI using the static DrawText and MeasureText methods offered by the TextRenderer class. The GDI methods also allow you to specify location, font, and format. You can choose either GDI or GDI+ for text rendering; however, GDI generally offers better performance and more accurate text measuring. Other classes that contribute to text rendering include FontFamily, Font, StringFormat, and TextFormatFlags.

How to: Construct Font Families and Fonts
Shows how to create Font and FontFamily objects.

How to: Draw Text at a Specified Location
Describes how to draw text in a certain location using GDI+ and GDI.

How to: Draw Wrapped Text in a Rectangle
Explains how to draw text in a rectangle using GDI+ and GDI.

How to: Draw Text with GDI
Demonstrates how to use GDI for drawing text.

How to: Align Drawn Text
Shows how to format GDI+ and GDI text.

How to: Create Vertical Text
Describes how to draw vertically aligned text with GDI+.

How to: Set Tab Stops in Drawn Text
Shows how draw text with tab stops with GDI+.

How to: Enumerate Installed Fonts
Explains how to list the names of installed fonts.

How to: Create a Private Font Collection
Describes how to create a PrivateFontCollection object.

How to: Obtain Font Metrics
Shows how to obtain font metrics such as cell ascent and descent.

How to: Use Antialiasing with Text
Explains how to use antialiasing when drawing text.

Font
Describes this class and contains links to all of its members.

FontFamily
Describes this class and contains links to all of its members.

PrivateFontCollection
Describes this class and contains links to all of its members.

TextRenderer
Describes this class and contains links to all of its members.

TextFormatFlags
Describes this class and contains links to all of its members.

Show: