Share via


TextRenderingHint Enum

Definisi

Menentukan kualitas penyajian teks.

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

Bidang

AntiAlias 4

Setiap karakter digambar menggunakan bitmap glyph antialias tanpa mengisyaratkan. Kualitas yang lebih baik karena antialias. Perbedaan lebar batang mungkin terlihat karena petunjuk dimatikan.

AntiAliasGridFit 3

Setiap karakter digambar menggunakan bitmap glyph antialias dengan petunjuk. Kualitas yang jauh lebih baik karena antialias, tetapi dengan biaya performa yang lebih tinggi.

ClearTypeGridFit 5

Setiap karakter digambar menggunakan bitmap ClearType glyph-nya dengan petunjuk. Pengaturan kualitas tertinggi. Digunakan untuk memanfaatkan fitur font ClearType.

SingleBitPerPixel 2

Setiap karakter digambar menggunakan bitmap glyph-nya. Petunjuk tidak digunakan.

SingleBitPerPixelGridFit 1

Setiap karakter digambar menggunakan bitmap glyph-nya. Petunjuk digunakan untuk meningkatkan penampilan karakter pada batang dan kelengkungan.

SystemDefault 0

Setiap karakter digambar menggunakan bitmap glyph-nya, dengan petunjuk penyajian default sistem. Teks akan digambar menggunakan pengaturan penghalusan font apa pun yang telah dipilih pengguna untuk sistem.

Contoh

Contoh kode berikut menunjukkan penggunaan TextRenderingHint properti dan TextContrast dan TextRenderingHint enumerasi.

Contoh ini dirancang untuk digunakan dengan Formulir Windows. Tempelkan kode ke dalam formulir dan panggil ChangeTextRenderingHintAndTextContrast metode saat menangani peristiwa formulir Paint , meneruskan e sebagai 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

Keterangan

Kualitasnya berkisar dari teks (performa tercepat, tetapi kualitas terendah) hingga teks antialisis (kualitas yang lebih baik, tetapi performa yang lebih lambat) hingga teks ClearType (kualitas terbaik pada tampilan LCD).

Berlaku untuk