TextRenderingHint 列舉

定義

指定文字呈現的品質。

C#
public enum TextRenderingHint
繼承
TextRenderingHint

欄位

名稱 Description
AntiAlias 4

不經提示,使用字元的反鋸齒補償圖像 (Glyph) 點陣圖繪製每個字元。 平滑化 (或稱反鋸齒補償) 可以產生較佳的品質。 縱線寬度的差異可能因為提示關閉而變得明顯。

AntiAliasGridFit 3

經由提示,使用字元的反鋸齒補償圖像點陣圖繪製每個字元。 平滑化 (反鋸齒補償) 可以產生較佳的品質,但卻會犧牲效能。

ClearTypeGridFit 5

經由提示,使用字元的圖像 ClearType 點陣圖繪製每個字元。 最高的品質設定。 用來利用 ClearType 字型的功能。

SingleBitPerPixel 2

使用字元的圖像點陣圖繪製每個字元。 不使用提示。

SingleBitPerPixelGridFit 1

使用字元的圖像點陣圖繪製每個字元。 提示是用來改善在縱線和彎曲上字元的外觀。

SystemDefault 0

經由系統預設呈現提示,使用字元的圖像點陣圖繪製每個字元。 使用任何使用者為系統所選取的字型平滑化設定來繪製文字。

範例

下列程式代碼範例示範 如何使用 TextRenderingHintTextContrast 屬性和 TextRenderingHint 列舉。

此範例的設計目的是要與 Windows Forms 搭配使用。 將程式代碼貼到表單中,並在處理表單的事件時呼叫 ChangeTextRenderingHintAndTextContrast 方法,並e傳遞為 PaintEventArgsPaint

C#
private void ChangeTextRenderingHintAndTextContrast(PaintEventArgs e)
{

    // Retrieve the graphics object.
    Graphics formGraphics = e.Graphics;

    // Declare a new font.
    Font myFont = new Font(FontFamily.GenericSansSerif, 20, 
        FontStyle.Regular);

    // Set the TextRenderingHint property.
    formGraphics.TextRenderingHint = 
        System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;

    // Draw the string.
    formGraphics.DrawString("Hello World", myFont, 
        Brushes.Firebrick, 20.0F, 20.0F);

    // Change the TextRenderingHint property.
    formGraphics.TextRenderingHint = 
        System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

    // Draw the string again.
    formGraphics.DrawString("Hello World", myFont, 
        Brushes.Firebrick, 20.0F, 60.0F);

    // Set the text contrast to a high-contrast setting.
    formGraphics.TextContrast = 0;

    // Draw the string.
    formGraphics.DrawString("Hello World", myFont, 
        Brushes.DodgerBlue, 20.0F, 100.0F);

    // Set the text contrast to a low-contrast setting.
    formGraphics.TextContrast = 12;

    // Draw the string again.
    formGraphics.DrawString("Hello World", myFont, 
        Brushes.DodgerBlue, 20.0F, 140.0F);

    // Dispose of the font object.
    myFont.Dispose();
}

備註

品質範圍從文字 (最快效能,但品質最低) 到反鋸齒文字 (品質較佳,但效能較慢,) 到 CLEARType 文字, (在) 上的最佳品質。

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9