GDI+绘制聚集在一起的字母
我觉得我读过类似的问题,但我找不到它,所以如果重复请关闭。
我正在尝试使用等宽字体(Consolas)使用 Graphics::DrawString
绘制文本。但是,当我绘制文本时,字母的间距不均匀。它看起来像这样:
正如您所看到的,这些字母聚集成两个和三个一组。我阅读了这篇文章,我认为我已经采取了足够的步骤来通过使用来避免它StringFormat::GenericTypography
,但显然不是。我还使用 TextRenderingHintClearTypeGridFit
因为所有其他看起来都像垃圾(并且没有 TextRenderingHintClearType
没有 GridFit
部分)。
如何像所有其他使用等宽字体绘制文本的程序一样绘制文本,使其看起来正确?
I feel like I've read a question similar to this but I can't find it, so please close if duplicate.
I am trying to draw text with Graphics::DrawString
with a monospace font (Consolas). However, when I draw the text, the letters are not evenly spaced. Here's what it looks like:
As you can see, the letters are clustered into groups of two and three. I read this article and I thought I had taken adequate steps to avoid it by using StringFormat::GenericTypographic
, but apparently not. I am also using TextRenderingHintClearTypeGridFit
because all the others look like junk (and there's no TextRenderingHintClearType
without the GridFit
part).
How can I draw text like all the other programs that draw text with a monospace font so that it looks right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 GDI+ 使用不同的(并且早已废弃的)系统来绘制文本。从 .NET Framework 2.0 开始,Microsoft 更改了所有控件,以实际使用 GDI 进行文本渲染,而不是 GDI+。 GDI 中的文本渲染是硬件加速的,并且通过字符渲染、Uniscribe、连字不断得到改进。 GDI+ 中的文本渲染不是硬件加速的,并且没有得到任何修复或改进。
GDI 还可以绘制抗锯齿,使用 CLEARTYPE_QUALITY 或 ANTIALIASED_QUALITY。
的比较
Graphics.DrawString
)TextRenderer.DrawText
)The issue is that GDI+ uses a different (and long since abandoned) system for drawing text. Starting with .NET framework 2.0, Microsoft changed all the controls to actually use GDI for text rendering, rather than GDI+. Text rendering in GDI is hardware accelerated, and continued to get improvements with character rendering, Uniscribe, ligatures. Text rendering in GDI+ is not hardware accelerated, and not getting any fixes or improvements.
GDI can also draw anti-aliased, use CLEARTYPE_QUALITY or ANTIALIASED_QUALITY.
Here's a comparison of
Graphics.DrawString
)TextRenderer.DrawText
)