TextRenderingHint-Enumeration
Gibt die Qualität der Textdarstellung an.
Namespace: System.Drawing.Text
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Enumeration TextRenderingHint
'Usage
Dim instance As TextRenderingHint
public enum TextRenderingHint
public enum class TextRenderingHint
public enum TextRenderingHint
public enum TextRenderingHint
Member
Membername | Beschreibung | |
---|---|---|
AntiAlias | Jedes Zeichen wird unter Verwendung der zugehörigen Symbolbitmap mit Antialiasing und ohne Hinting gezeichnet. Bessere Qualität aufgrund von Antialiasing. Unterschiede in der Stammbreite können erkennbar sein, da Hinting ausgeschaltet ist. | |
AntiAliasGridFit | Jedes Zeichen wird unter Verwendung der zugehörigen Symbolbitmap mit Antialiasing und mit Hinting gezeichnet. Wesentlich bessere Qualität durch Antialiasing, jedoch bei höheren Leistungsverlusten. | |
ClearTypeGridFit | Jedes Zeichen wird unter Verwendung der zugehörigen ClearType-Symbolbitmap mit Hinting gezeichnet. Die Einstellung mit der höchsten Qualität. Wird verwendet, um die Features der ClearType-Schriftart nutzen zu können. | |
SingleBitPerPixel | Jedes Zeichen wird unter Verwendung der zugehörigen Symbolbitmap gezeichnet. Hinting wird nicht verwendet. | |
SingleBitPerPixelGridFit | Jedes Zeichen wird unter Verwendung der zugehörigen Symbolbitmap gezeichnet. Durch Hinting wird die Darstellung der Stämme und Bögen von Zeichen verbessert. | |
SystemDefault | Jedes Zeichen wird unter Verwendung der zugehörigen Symbolbitmap mit dem Standardhinting des Systems gezeichnet. Der Text wird mit den Einstellungen für die Schriftartglättung gezeichnet, die der Benutzer für das System ausgewählt hat. |
Hinweise
Die Qualitätsspanne reicht von Text (schnellste Darstellung, aber geringste Qualität) über Text mit Antialiasing (bessere Qualität, aber langsamere Darstellung) bis zu ClearType-Text (beste Qualität bei einer LCD-Anzeige).
Beispiel
Im folgenden Codebeispiel wird die Verwendung der TextRenderingHint-Eigenschaft und der TextContrast-Eigenschaft sowie der TextRenderingHint-Enumeration veranschaulicht.
Dieses Beispiel ist für die Verwendung mit Windows Forms vorgesehen. Fügen Sie den Code in ein Formular ein, und rufen Sie beim Behandeln des Paint-Ereignisses des Formulars die ChangeTextRenderingHintAndTextContrast
-Methode auf, wobei Sie e als PaintEventArgs übergeben.
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
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:
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.get_Graphics();
// Declare a new font.
Font myFont = new Font(FontFamily.get_GenericSansSerif(),
20, FontStyle.Regular);
// Set the TextRenderingHint property.
formGraphics.set_TextRenderingHint(System.Drawing.Text.
TextRenderingHint.SingleBitPerPixel);
// Draw the string.
formGraphics.DrawString("Hello World", myFont,
Brushes.get_Firebrick(), 20, 20);
// Change the TextRenderingHint property.
formGraphics.set_TextRenderingHint(System.Drawing.Text.
TextRenderingHint.AntiAliasGridFit);
// Draw the string again.
formGraphics.DrawString("Hello World", myFont,
Brushes.get_Firebrick(), 20, 60);
// Set the text contrast to a high-contrast setting.
formGraphics.set_TextContrast(0);
// Draw the string.
formGraphics.DrawString("Hello World", myFont,
Brushes.get_DodgerBlue(), 20, 100);
// Set the text contrast to a low-contrast setting.
formGraphics.set_TextContrast(12);
// Draw the string again.
formGraphics.DrawString("Hello World", myFont,
Brushes.get_DodgerBlue(), 20, 140);
// Dispose of the font object.
myFont.Dispose();
} //ChangeTextRenderingHintAndTextContrast
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0