TextRenderingHint Výčet

Definice

Určuje kvalitu vykreslování textu.

public enum class TextRenderingHint
public enum TextRenderingHint
type TextRenderingHint = 
Public Enum TextRenderingHint
Dědičnost
TextRenderingHint

Pole

Name Hodnota Description
SystemDefault 0

Každý znak je nakreslen pomocí rastrového obrázku glyf s výchozím nápovědou pro vykreslení systému. Text bude nakreslen pomocí libovolného nastavení vyhlazování písma, které uživatel vybral pro systém.

SingleBitPerPixelGridFit 1

Každý znak je nakreslen pomocí rastrového obrázku. Tipování se používá ke zlepšení vzhledu znaků na kmenech a zakřivení.

SingleBitPerPixel 2

Každý znak je nakreslen pomocí rastrového obrázku. Nápovědu se nepoužívá.

AntiAliasGridFit 3

Každý znak je vykreslen pomocí jeho antialiased glyph bitmap s nápovědou. Mnohem lepší kvalita kvůli antialiasingu, ale s vyššími náklady na výkon.

AntiAlias 4

Každý znak je vykreslen pomocí jeho antialiased glyph bitmap bez nápovědy. Lepší kvalita z důvodu antialiasingu. Rozdíly v šířce kmene můžou být patrné, protože je vypnutá nápověda.

ClearTypeGridFit 5

Každý znak je nakreslen pomocí rastrového obrázku ClearType glyph s nápovědou. Nastavení nejvyšší kvality. Používá se k využití funkcí písma ClearType.

Příklady

Následující příklad kódu ukazuje použití TextRenderingHint a TextContrast vlastnosti a výčtu TextRenderingHint .

Tento příklad je navržený tak, aby se používal s model Windows Forms. Vložte kód do formuláře a zavolejte metodu ChangeTextRenderingHintAndTextContrast při zpracování události formuláře Paint a předejte 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

Poznámky

Kvalita se pohybuje od textu (nejrychlejší výkon, ale nejnižší kvalita) až po antialiased text (lepší kvalita, ale pomalejší výkon) až ClearType text (nejlepší kvalita na LCD displeji).

Platí pro