Posts

Showing posts from January, 2011

Antialiasing Text with C#

Image
Lately I have found myself having to use anti-aliasing in a lot of our rendering code to improve the output look our images.  To help others here is a snippet of code to anti alias text. protected override void OnPaint( PaintEventArgs e ) {     base.OnPaint( e );     Font font = new Font( "Tahoma", 12.0f, FontStyle.Regular );     e.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;     TextRenderer.DrawText( e.Graphics, "Antialiased Text", font, new Point( 0, 20 ), Color.Black );      e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;      TextRenderer.DrawText( e.Graphics, "Antialiased Text", font, new Point( 0, 40 ), Color.Black );     e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;     TextRenderer.DrawText( e.Graphics, "Antialiased Text", font, new Point( 0, 60 ), Color.Black );     e....