TextRenderingHint Enumeration

Definition

Gibt die Qualität des Textrenderings an.

public enum class TextRenderingHint
public enum TextRenderingHint
type TextRenderingHint = 
Public Enum TextRenderingHint
Vererbung
TextRenderingHint

Felder

Name Wert Beschreibung
SystemDefault 0

Jedes Zeichen wird mit der Glyphenbitmap gezeichnet, wobei der standardmäßige Renderinghinweis des Systems verwendet wird. Der Text wird mit allen Einstellungen für die Schriftartglättung gezeichnet, die der Benutzer für das System ausgewählt hat.

SingleBitPerPixelGridFit 1

Jedes Zeichen wird mithilfe der Glyphenbitmap gezeichnet. Hinweise werden verwendet, um das Aussehen von Zeichen auf Stielen und Krümmungen zu verbessern.

SingleBitPerPixel 2

Jedes Zeichen wird mithilfe der Glyphenbitmap gezeichnet. Hinweis wird nicht verwendet.

AntiAliasGridFit 3

Jedes Zeichen wird mit der antialiasierten Glyphenbitmap mit Hinweis gezeichnet. Viel bessere Qualität aufgrund von Antialiasing, aber zu höheren Leistungskosten.

AntiAlias 4

Jedes Zeichen wird mit der antialiasierten Glyphenbitmap gezeichnet, ohne darauf hinweisen zu müssen. Bessere Qualität durch Antialiasing. Unterschiede bei der Stammbreite können erkennbar sein, da der Hinweis deaktiviert ist.

ClearTypeGridFit 5

Jedes Zeichen wird mit der Glyphen-ClearType-Bitmap mit Hinweis gezeichnet. Die höchste Qualitätseinstellung. Wird verwendet, um die Vorteile von ClearType-Schriftartfeatures zu nutzen.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der TextRenderingHint Eigenschaften und TextContrast der TextRenderingHint Enumeration veranschaulicht.

Dieses Beispiel wurde für die Verwendung mit Windows Forms entwickelt. Fügen Sie den Code in ein Formular ein, und rufen Sie die ChangeTextRenderingHintAndTextContrast Methode beim Behandeln des Formularereignisses Paint auf und übergeben als ePaintEventArgs.

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

Hinweise

Die Qualität reicht von Text (schnellste Leistung, aber niedrigste Qualität) bis hin zu antialiasiertem Text (bessere Qualität, aber langsamere Leistung) bis ClearType-Text (beste Qualität auf einem LCD-Display).

Gilt für: