Graphics.DrawString 与 TextRenderer.DrawText 哪个可以提供更好的质量 [英] Graphics.DrawString vs TextRenderer.DrawText?Which can Deliver Better Quality

查看:26
本文介绍了Graphics.DrawString 与 TextRenderer.DrawText 哪个可以提供更好的质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TextRenderer 基于 GDI,Graphics.DrawString 基于 GDI+.在图像上绘制文本时,这些函数中的哪一个可以提供更好的文本质量.

TextRenderer is based on GDI and Graphics.DrawString is based on GDI+.Which of these functions can deliver better quality text while drawing text on an image.

推荐答案

我的 2 美分:我总是使用 Graphics.DrawString,除非当我需要为我的(Windows 窗体)进行自定义绘画时控件.例如,在设置了 OwnerDraw 的列表框中,如果我附加了一个完全绘制项目(包括项目文本)的 DrawItem 事件处理程序.或者在自定义控件中我必须自己绘制.

Just my 2 cents: I always use Graphics.DrawString, except when I need to do custom painting for my (Windows Forms) controls. For example in a listbox that has OwnerDraw set, if I attach a DrawItem event handler that fully paints items, including item text. Or in a custom control I have to paint myself.

在支持视觉样式并启用它的操作系统上使用视觉样式的应用程序中,与其他控件绘制的常规文本相比,使用 Graphics.DrawString 绘制的文本看起来关闭".这似乎主要是因为处理(或不处理)ClearType"的方式存在差异,尽管我不确定并且我没有支持该声明的文档.(它有点像文本在 .Net 1.x 上的表现方式,或者将 FlatStyle 从 Standard 切换到 System 和 v.v. 时的方式)

In an application that uses Visual Styles on an OS that supports it and has it enabled, text drawn with Graphics.DrawString looks "off" when compared to regular text drawn by other controls. This appears to be mainly because of differences in the way "ClearType" is (or is not) handled, although I am not sure and I do not have docs to back that statement up. (It sort of looks like the way text did on .Net 1.x or when switching FlatStyle from Standard to System and v.v.)

仅在这种情况下(Winforms 控件上的文本绘制)我使用 TextRenderer.DrawText 使文本更好地与其他控件融合.

In such cases only (text painting on Winforms controls) I use TextRenderer.DrawText to make the text better blend in with the other controls.

如果与当地人融合"不是您的顾虑之一(看起来像,因为您想在图像上绘制),我会选择 Graphics.DrawString.此外,如果您想要打印,则必须,因为 TextRenderer 仅适用于屏幕(而不是打印机画布).

If "blending in with the natives" is not one of your concerns (which it looks like, since you want to draw on an image) I'd go for Graphics.DrawString. Also, if you'd want printing, you must, since TextRenderer only works on screen (not the printer canvas).

这篇关于Graphics.DrawString 与 TextRenderer.DrawText 哪个可以提供更好的质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆