使用字型和文字Using Fonts and Text

有數個 Windows Form 上繪製文字的 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.