TextRenderingHint Перечисление
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Указывает качество отрисовки текста.
public enum class TextRenderingHint
public enum TextRenderingHint
type TextRenderingHint =
Public Enum TextRenderingHint
- Наследование
Поля
| Имя | Значение | Описание |
|---|---|---|
| SystemDefault | 0 | Каждый символ рисуется с помощью растрового изображения глифа с указанием отрисовки по умолчанию по умолчанию. Текст будет нарисован с помощью параметров сглаживания шрифтов, выбранных пользователем для системы. |
| SingleBitPerPixelGridFit | 1 | Каждый символ рисуется с помощью растрового изображения глифа. Указание используется для улучшения внешнего вида символов на стеблях и кривизне. |
| SingleBitPerPixel | 2 | Каждый символ рисуется с помощью растрового изображения глифа. Указание не используется. |
| AntiAliasGridFit | 3 | Каждый символ рисуется с помощью растрового рисунка с указанием антиализасного глифа. Гораздо лучшее качество из-за антиализа, но при более высоких затратах на производительность. |
| AntiAlias | 4 | Каждый символ рисуется с помощью растрового изображения с антиалиасным глифом без указания. Лучшее качество из-за антиализа. Различия ширины стебля могут быть заметными, так как указание отключено. |
| ClearTypeGridFit | 5 | Каждый символ рисуется с помощью растрового изображения ClearType с указанием. Самый высокий уровень качества. Используется для использования функций шрифта ClearType. |
Примеры
В следующем примере кода показано использование TextRenderingHint и TextContrast свойства и перечисление TextRenderingHint .
Этот пример предназначен для использования с Windows Forms. Вставьте код в форму и вызовите ChangeTextRenderingHintAndTextContrast метод при обработке события формы Paint , передавая e как 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
Комментарии
Качество диапазонов от текста (самая быстрая производительность, но наименьшее качество) до антиалисированного текста (лучшее качество, но более низкая производительность) до текста ClearType (лучшее качество на дисплее LCD).