Font is very ugly
I'm drawing a string with the folowing code:
public Image DrawString(String lString)开发者_如何学C
{
Image lImage = new Bitmap(128, 128);
Rectangle rec = new Rectangle(0, 0, lImage.Width, lImage.Height);
Graphics g = Graphics.FromImage(lImage);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
drawFormat.LineAlignment = StringAlignment.Center;
Font font = new Font("Arial", 20, FontStyle.Regular);
font = FindBestFitFont(g, lString, font, rec.Size);
g.DrawString(lString, font, Brushes.Red, rec, drawFormat);
return lImage;
}
The font looks very ugly even when i use:
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
Is there a way to make the font more smooth?
Try
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
instead.
Have you tried AntiAliasing or ClearType?
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
精彩评论