Aero: How to draw ClearType text on glass?

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:

alt text

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

alt text

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

alt text

And here is no font smoothing:

alt text

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

11
задан Community 23 May 2017 в 12:24
поделиться