Permalink
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (61 sloc) 5.03 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Using Fonts and Text
03/30/2017
.net-framework
dotnet-winforms
article
jsharp
GDI, drawing text [Windows Forms]
text [Windows Forms], drawing in Windows Forms
examples [Windows Forms], fonts and text
fonts, using in Windows Forms
strings [Windows Forms], drawing in Windows Forms
d43640f3-da94-4df2-a29d-a9d021a1c069
16
dotnet-bot
dotnetcontent
wpickett

Using Fonts and Text

There are several classes offered by [!INCLUDEndptecgdiplus] and [!INCLUDEndptecgdi] for drawing text on Windows Forms. The [!INCLUDEndptecgdiplus] xref:System.Drawing.Graphics class has several xref:System.Drawing.Graphics.DrawString%2A 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 [!INCLUDEndptecgdi] using the static xref:System.Windows.Forms.TextRenderer.DrawText%2A and xref:System.Windows.Forms.TextRenderer.MeasureText%2A methods offered by the TextRenderer class. The [!INCLUDEndptecgdi] methods also allow you to specify location, font, and format. You can choose either [!INCLUDEndptecgdi] or [!INCLUDEndptecgdiplus] for text rendering; however, [!INCLUDEndptecgdi] generally offers better performance and more accurate text measuring. Other classes that contribute to text rendering include FontFamily, Font, xref:System.Drawing.StringFormat, and TextFormatFlags.

In This Section

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 [!INCLUDEndptecgdiplus] and [!INCLUDEndptecgdi].

How to: Draw Wrapped Text in a Rectangle
Explains how to draw text in a rectangle using [!INCLUDEndptecgdiplus] and [!INCLUDEndptecgdi].

How to: Draw Text with GDI
Demonstrates how to use [!INCLUDEndptecgdi] for drawing text.

How to: Align Drawn Text
Shows how to format [!INCLUDEndptecgdiplus] and [!INCLUDEndptecgdi] text.

How to: Create Vertical Text
Describes how to draw vertically aligned text with [!INCLUDEndptecgdiplus].

How to: Set Tab Stops in Drawn Text
Shows how draw text with tab stops with [!INCLUDEndptecgdiplus].

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 xref:System.Drawing.Text.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.

Reference

xref:System.Drawing.Font
Describes this class and contains links to all of its members.

xref:System.Drawing.FontFamily
Describes this class and contains links to all of its members.

xref:System.Drawing.Text.PrivateFontCollection
Describes this class and contains links to all of its members.

xref:System.Windows.Forms.TextRenderer
Describes this class and contains links to all of its members.

xref:System.Windows.Forms.TextFormatFlags
Describes this class and contains links to all of its members.