Can I install TextRenderingHint for the entire application?

I want to use anti-aliased fonts in a C # application. I read here how this can be done with the Paint event of each form:

public class SmoothingFonts : System.Windows.Forms.Form
{
    ...

    private void InitializeComponent()
    {
        ...

        this.Paint += this.SmoothingFonts_Paint;
    }

    private void SmoothingFonts_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
        Font TextFont = new Font("Verdana", 25, FontStyle.Italic);
        e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
        e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 20, 150);
    }
}

This can become cumbersome because we already have many forms. In addition, in each form we use several types of forms. Can I set the setting for TextRenderingHintall over the world?


EDIT 1

The given example, although it is outdated, as correctly indicated by nobugz , helped me understand that the best TextRenderingHintthat will be used in this system is the AntiAliasGridFithardware platform is closed, so I can assure that this is the best configuration for this system, it will be the best for all systems in which the application will be deployed.

TextRenderingHint ? Windows Embedded Standard ( Windows XP Embedded).


2

, XP TextRenderingHint, . , . :

HKCU\Control Panel\Desktop\FontSmoothing      {2 for activating font smoothing}
HKCU\Control Panel\Desktop\FontSmoothingType  {1 for Antialiasing, 2 for ClearType}

!

+3
2

. ClearTypeGridFit ClearType. TextRenderer , Graphics.DrawString() .

, ClearType ZoomIt SysInternals. , , .

+2

GDI TextRenderer, . DrawText Graphics as ,

  TextRenderer.DrawText(    e.Graphics,
                            "Text",
                            font,
                            textRect,
                            ForeColor,
                            BackColor
                            );
0

Source: https://habr.com/ru/post/1732167/


All Articles