How to: Use Antialiasing with Text
Antialiasing refers to the smoothing of jagged edges of drawn graphics and text to improve their appearance or readability. With the managed GDI+ classes, you can render high quality antialiased text, as well as lower quality text. Typically, higher quality rendering takes more processing time than lower quality rendering. To set the text quality level, set theproperty of a to one of the elements of the enumeration
The following code example draws text with two different quality settings.
The following illustration shows the output of the cod example code.
FontFamily fontFamily = new FontFamily("Times New Roman"); Font font = new Font( fontFamily, 32, FontStyle.Regular, GraphicsUnit.Pixel); SolidBrush solidBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255)); string string1 = "SingleBitPerPixel"; string string2 = "AntiAlias"; e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel; e.Graphics.DrawString(string1, font, solidBrush, new PointF(10, 10)); e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; e.Graphics.DrawString(string2, font, solidBrush, new PointF(10, 60));
Compiling the Code
The preceding code example is designed for use with Windows Forms, and it requires e, which is a parameter of .