使用字体和文本Using Fonts and Text

还有几个类为在 Windows 窗体上绘制文本提供通过 GDI + 和 GDI。There are several classes offered by GDI+ and GDI for drawing text on Windows Forms. GDI +Graphics类具有多个DrawString,可以指定的文本,例如位置、 边框矩形、 字体和格式的各种功能的方法。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. 此外,可以绘制和度量的文本值与使用静态的 GDIDrawTextMeasureText方法提供的TextRenderer类。In addition, you can draw and measure text with GDI using the static DrawText and MeasureText methods offered by the TextRenderer class. GDI 方法还允许您指定位置、 字体和格式。The GDI methods also allow you to specify location, font, and format. 你可为文本呈现; 选择 GDI 或 GDI +但是,GDI 通常提供更好的性能,并且正在测量更准确的文本。You can choose either GDI or GDI+ for text rendering; however, GDI generally offers better performance and more accurate text measuring. 涉及文本呈现其他类包括FontFamilyFontStringFormat,和TextFormatFlagsOther classes that contribute to text rendering include FontFamily, Font, StringFormat, and TextFormatFlags.

本节内容In This Section

如何:构造字体系列和字体How to: Construct Font Families and Fonts
演示如何创建FontFontFamily对象。Shows how to create Font and FontFamily objects.

如何:在指定位置绘制文本How to: Draw Text at a Specified Location
介绍如何在某个位置使用 GDI + 和 GDI 绘制文本。Describes how to draw text in a certain location using GDI+ and GDI.

如何:在矩形中绘制换行文本How to: Draw Wrapped Text in a Rectangle
介绍如何在使用 GDI + 和 GDI 的矩形中绘制文本。Explains how to draw text in a rectangle using GDI+ and GDI.

如何:用 GDI 绘制文本How to: Draw Text with GDI
演示如何使用 GDI 绘制文本。Demonstrates how to use GDI for drawing text.

如何:对齐绘制的文本How to: Align Drawn Text
演示如何设置 GDI + 和 GDI 文本的格式。Shows how to format GDI+ and GDI text.

如何:创建垂直文本How to: Create Vertical Text
描述如何绘制使用 GDI + 的垂直对齐的文本。Describes how to draw vertically aligned text with GDI+.

如何:在绘制的文本中设置制表位How to: Set Tab Stops in Drawn Text
显示了如何绘制使用 GDI + 选项卡停止使用的文本。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
介绍如何创建PrivateFontCollection对象。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.

参考Reference

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.