TextRenderingHint 列舉

定義

指定文字呈現的品質。Specifies the quality of text rendering.

public enum class TextRenderingHint
public enum TextRenderingHint
type TextRenderingHint = 
Public Enum TextRenderingHint
繼承
TextRenderingHint

欄位

AntiAlias 4

不經提示,使用字元的反鋸齒補償圖像 (Glyph) 點陣圖繪製每個字元。Each character is drawn using its antialiased glyph bitmap without hinting. 平滑化 (或稱反鋸齒補償) 可以產生較佳的品質。Better quality due to antialiasing. 縱線寬度的差異可能因為提示關閉而變得明顯。Stem width differences may be noticeable because hinting is turned off.

AntiAliasGridFit 3

經由提示,使用字元的反鋸齒補償圖像點陣圖繪製每個字元。Each character is drawn using its antialiased glyph bitmap with hinting. 平滑化 (反鋸齒補償) 可以產生較佳的品質,但卻會犧牲效能。Much better quality due to antialiasing, but at a higher performance cost.

ClearTypeGridFit 5

經由提示,使用字元的圖像 ClearType 點陣圖繪製每個字元。Each character is drawn using its glyph ClearType bitmap with hinting. 最高的品質設定。The highest quality setting. 用來利用 ClearType 字型的功能。Used to take advantage of ClearType font features.

SingleBitPerPixel 2

使用字元的圖像點陣圖繪製每個字元。Each character is drawn using its glyph bitmap. 不使用提示。Hinting is not used.

SingleBitPerPixelGridFit 1

使用字元的圖像點陣圖繪製每個字元。Each character is drawn using its glyph bitmap. 提示是用來改善在縱線和彎曲上字元的外觀。Hinting is used to improve character appearance on stems and curvature.

SystemDefault 0

經由系統預設呈現提示,使用字元的圖像點陣圖繪製每個字元。Each character is drawn using its glyph bitmap, with the system default rendering hint. 使用任何使用者為系統所選取的字型平滑化設定來繪製文字。The text will be drawn using whatever font-smoothing settings the user has selected for the system.

範例

下列程式碼範例示範如何使用 TextRenderingHintTextContrast 屬性和 TextRenderingHint 列舉。The following code example demonstrates the use of the TextRenderingHint and TextContrast properties and the TextRenderingHint enumeration.

這個範例是設計來與 Windows Forms 搭配使用。This example is designed to be used with Windows Forms. 將程式碼貼入表單,並在處理表單的 Paint 事件時呼叫 ChangeTextRenderingHintAndTextContrast 方法,並以 PaintEventArgs傳遞 ePaste the code into a form and call the ChangeTextRenderingHintAndTextContrast method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void ChangeTextRenderingHintAndTextContrast( PaintEventArgs^ e )
   {
      // Retrieve the graphics object.
      Graphics^ formGraphics = e->Graphics;

      // Declare a new font.
      System::Drawing::Font^ myFont = gcnew System::Drawing::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.
      delete myFont;
   }
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();
}
Private Sub ChangeTextRenderingHintAndTextContrast(ByVal e As _
    PaintEventArgs)

    ' Retrieve the graphics object.
    Dim formGraphics As Graphics = e.Graphics

    ' Declare a new font.
    Dim myFont As Font = 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()

End Sub

備註

品質範圍從文字(最快的效能,但品質最低)到 ClearType 文字(較佳的品質,但效能較慢),最高可達 ClearType (LCD 顯示器的品質)。The quality ranges from text (fastest performance, but lowest quality) to antialiased text (better quality, but slower performance) to ClearType text (best quality on an LCD display).

適用於