Aero: How to draw ClearType text on glass?

寵の児 提交于 2019-11-27 01:57:01

问题


Using GDI+ to draw text on glass:

graphics.DrawString(s, Length(s), font, MakePointF(x, y), brush);

You'll notice that the ClearType enabled text draws very poorly on glass:

But with glass disabled the text, of course, draw fine:

By way of comparison here is Anti-alias font smoothing:

And here is no font smoothing:

Note: No font smoothing looks better than it really does because StackOverflow resizes the images on your monitor.

How do i draw ClearType text on glass?

Notes

  • Win32 native
  • not .NET (i.e. native)
  • not Winforms (i.e. native)
  • GDI+ (i.e. native)

What Mark is suggesting is that you cannot honor the user's preferences for text rendering (i.e. "SystemDefault". ClearType does not function on glass, and you cannot use it.

In other words, if you're rendering on glass you must override the text rendering with:

graphics.SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);

Otherwise you should leave the TextRenderingHint at it's default TextRenderingHintSystemDefault.

See also

  • Aero: How to draw solid colors on glass?
  • Windows Aero: What color to paint to make “glass” appear?
  • WPF: Extending glass into client area disables ClearType entirely

回答1:


The problem is inherent to the way drawing is performed. All of your text is being drawn on a black background, then composited onto a glass background; the semi-transparent font smoothing is being combined with black to make near-black.



来源:https://stackoverflow.com/questions/4258330/aero-how-to-draw-cleartype-text-on-glass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!