Mega Code Archive

 
Categories / C# / 2D Graphics
 

TextRenderingHint

using System; using System.Drawing; using System.Drawing.Text; using System.Windows.Forms;     class AntiAliasedText: Form {      public static void Main()      {           Application.Run(new AntiAliasedText());      }      public AntiAliasedText()      {           Font = new Font("Times New Roman", 12);           ResizeRedraw = true;       }      protected override void OnPaint(PaintEventArgs pea)      {           DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);      }           protected void DoPage(Graphics grfx, Color clr, int cx, int cy)      {           Brush  brush  = new SolidBrush(clr);           string str    = "A ";           int    cxText = (int) grfx.MeasureString(str, Font).Width;               for (int i = 0; i < 6; i++)           {                grfx.TextRenderingHint = (TextRenderingHint)i;                grfx.DrawString(str, Font, brush, i * cxText, 0);           }      } }