gpt4 book ai didi

c# - 字体非常难看

转载 作者:行者123 更新时间:2023-11-30 14:03:03 25 4
gpt4 key购买 nike

我正在使用以下代码绘制一个字符串:

public Image DrawString(String lString)
{
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;
}

字体看起来很丑,即使我使用:

g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;

有没有办法让字体更流畅?

最佳答案

尝试

g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

相反。

关于c# - 字体非常难看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4723788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com