Question

Anti aliasing cannot be turned off in WPF. But I want to remove the blurred look of WPF fonts when they are small.

One possibility would be to use a .net 2.0 component. This looks like it would lose the transparency capability and Blend support. Never tried it though.

Anyone has a solution for this? Any drawbacks from it?

Thank you

Was it helpful?

Solution

Have you tried putting a WindowsFormsHost control on a WPF window/control? That will allow WPF to render a WinForms control.

UPDATE November 2012: This question and answer is 4 years old. Text rendering has since improved in WPF. Please don't put WinForms controls in WPF apps; that was a hackish way to fix font rendering. It's no longer needed.

OTHER TIPS

Anti-Alias can be turned off starting WPF 4.0 with following option:

TextOptions.TextFormattingMode="Display"

SnapsToDevicePixels has absolutely no effect on text rendering.

Microsoft have a blog dedicated to text rendering in WPF here WPF Text Blog

Things have definitely improved in .NET 4.0.

Offset the objects you draw, that you don't want to be antialiased, by 0.5px. This will cause the drawing engine to draw on the actual pixels, rather than drawing on the edge of the pixels (which is the default). When drawing on the edge of a pixel antialiasing normally occurs on the surrounding pixels.

This is similar to Quarts drawing on Mac.

Edit: Sorry, I didn't read the question. This doesn't work for fonts, only for shapes. I will leave the comment here for reference, though.

Try using the UIElement.SnapsToDevicePixels property on the UI elements of your window. People tend to report it works best for graphics and lines, but I've noticed improvment in text rendering with it as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top