TextRenderingHint Wyliczenie

Definicja

Określa jakość renderowania tekstu.

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

Pola

AntiAlias 4

Każdy znak jest rysowany przy użyciu antyaliased mapy bitowej glyph bez podpowiedzi. Lepsza jakość ze względu na antyaliasing. Różnice szerokości stem mogą być zauważalne, ponieważ wskazówki są wyłączone.

AntiAliasGridFit 3

Każdy znak jest rysowany przy użyciu antyaliased mapy bitowej glyph z wskazówką. Znacznie lepsza jakość ze względu na antyaliasing, ale przy wyższych kosztach wydajności.

ClearTypeGridFit 5

Każdy znak jest rysowany przy użyciu mapy bitowej ClearType z wskazówką. Ustawienie najwyższej jakości. Służy do korzystania z funkcji czcionek ClearType.

SingleBitPerPixel 2

Każdy znak jest rysowany przy użyciu mapy bitowej glyph. Wskazówki nie są używane.

SingleBitPerPixelGridFit 1

Każdy znak jest rysowany przy użyciu mapy bitowej glyph. Wskazówka służy do poprawy wyglądu postaci na łodygach i krzywiznach.

SystemDefault 0

Każdy znak jest rysowany przy użyciu mapy bitowej glyph z domyślną wskazówką renderowania systemu. Tekst zostanie narysowany przy użyciu dowolnych ustawień wygładzających czcionkę wybranych przez użytkownika dla systemu.

Przykłady

Poniższy przykład kodu przedstawia użycie TextRenderingHint właściwości i TextContrast oraz wyliczenie TextRenderingHint .

Ten przykład jest przeznaczony do użycia z Windows Forms. Wklej kod do formularza i wywołaj ChangeTextRenderingHintAndTextContrast metodę podczas obsługi zdarzenia formularza Paint , przekazując e jako 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

Uwagi

Jakość waha się od tekstu (najszybsza wydajność, ale najniższa jakość) do antyaliasowanego tekstu (lepsza jakość, ale niższa wydajność) do tekstu ClearType (najlepsza jakość na wyświetlaczu LCD).

Dotyczy