Hello,
I wanto to use antialiased fonts in a C# application. I have read here how 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 could get cumbersome because we already have many forms done. Also, in every form we use several forms types. Can the setting for TextRenderingHint be set globally?
EDIT 1
The example cited, eventhough it's outdated as correctly pointed by nobugz, helped me to realise that the best TextRenderingHint to be used in this system is AntiAliasGridFit. The hardware platform is closed, so I can assure that it is the best configuration for this system will be the best for all the systems where the application will be deployed.
Can I set the default setting for the TextRenderingHint anywhere? I'm running the application in a Windows Embedded Standard (former Windows XP Embedded) image.
EDIT 2
I found that in a XP system you can set the type of TextRenderingHint used by the default by the registry. It is not a by application method, but a by user method. The registry keys are:
HKCU\Control Panel\Desktop\FontSmoothing {2 for activating font smoothing}
HKCU\Control Panel\Desktop\FontSmoothingType {1 for Antialiasing, 2 for ClearType}
Thanks for the support!