TextRenderer.DrawText 使用 GDI 渲染 OTF 字体?
我正在尝试在位图图像上绘制文本,我做了一些研究,发现 .NET/GDI+ 不支持 OTF 字体。我在某处读到,您可以使用 TextRenderer.DrawText
通过 GDI 渲染 OTF 字体,但我似乎不知道如何操作,质量也无法与 Graphics.DrawString
相比> 至少一点点。
首先,在VS中是否可以使用OTF字体,或者我读错了什么?
第二,如果答案是TextRenderer.DrawText,我该如何使用OTF字体?看起来我必须使用 System.Drawing.Font 类,但我认为它们不支持字体,这就是问题,对吗?
如何让字体像使用 GDI+ 的 TTF 字体一样清晰呈现 (
Graphics.DrawString
)使用
Graphics.DrawString
我能够使用RectangleF
(具有指定的宽度,0 高度)作为我的文本的边界,并且文本换行正确。使用TextRenderer.DrawText
,使用RectangleF
的功能消失,只允许使用Rectangle
,它似乎不允许 0 高度,同时仍然允许文本显示(即文本必须在矩形内,文本换行不起作用)。我做错了吗?
任何帮助将不胜感激。如果无法做到这一点,有没有办法转换 OTF 字体,或者在线找到 Gotham 字体系列的 TTF 版本?我真的很需要这些字体!
I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText
to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString
in the least bit.
First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly?
Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It looks like I have to use the
System.Drawing.Font
class, but I don't think those support the fonts and that's the issue, correct?How do I get the fonts to render clearly like the TTF fonts using GDI+ (
Graphics.DrawString
)Using
Graphics.DrawString
I was able to use aRectangleF
(with specified width, 0 height) as a boundary for my text, and the text wrapped correctly. WithTextRenderer.DrawText
, the ability to useRectangleF
disappears and only allowsRectangle
which doesn't seem to allow 0 height, while still allowing text to display (ie. text must be within the rectangle, and text wrapping does not work). Am I doing it wrong?
Any help would be greatly appreciated. If this cannot be done, is there a way to convert the OTF fonts, or find the Gotham font family online in TTF version? I really need these fonts!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论