英語で読む

次の方法で共有


TextRenderingHint 列挙型

定義

テキスト レンダリングの品質を指定します。

C#
public enum TextRenderingHint
継承
TextRenderingHint

フィールド

名前 説明
AntiAlias 4

アンチエイリアス処理されたグリフ ビットマップを使用して、ヒンティングなしに各文字を描画します。 アンチエイリアスによって品質が向上します。 ヒンティングがオフにされるため、ステム幅の違いが目立ちます。

AntiAliasGridFit 3

アンチエイリアス処理されたグリフ ビットマップを使用して、ヒンティングありで各文字を描画します。 アンチエイリアスによってより高い品質が得られますが、パフォーマンスは大きく低下します。

ClearTypeGridFit 5

グリフ ClearType ビットマップを使用して、ヒンティングありで各文字を描画します。 最高の品質設定です。 ClearType テキスト フォント機能を利用するときに使用します。

SingleBitPerPixel 2

グリフ ビットマップを使用して各文字を描画します。 ヒンティングは使用されません。

SingleBitPerPixelGridFit 1

グリフ ビットマップを使用して各文字を描画します。 ヒンティングを使用して、文字のステム部分と曲線部分の見た目を向上します。

SystemDefault 0

グリフ ビットマップを使用し、システムの既定のレンダリング ヒントで各文字を描画します。 ユーザーがシステムで選択した、すべてのフォント スムージング設定を使用してテキストを描画します。

次のコード例では、 プロパティと TextContrast プロパティと 列挙体のTextRenderingHint使用方法をTextRenderingHint示します。

この例は、Windows フォームで使用するように設計されています。 フォームにコードを貼り付け、フォームのイベントをChangeTextRenderingHintAndTextContrast処理するときに メソッドをPaint呼び出し、 を としてPaintEventArgs渡しますe

C#
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();
}

注釈

品質の範囲は、テキスト (最速のパフォーマンス、低品質) からアンチエイリアス化されたテキスト (品質は向上しますが、パフォーマンスは低下します) から ClearType テキスト (LCD ディスプレイで最高の品質) までです。

適用対象

製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9