Reputation: 7167
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?
Upvotes: 10
Views: 13678
Reputation: 60051
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.
Upvotes: 3
Reputation: 908
Anti-Alias can be turned off starting WPF 4.0 with following option:
TextOptions.TextFormattingMode="Display"
Upvotes: 10
Reputation: 1363
Microsoft have a blog dedicated to text rendering in WPF here WPF Text Blog
Things have definitely improved in .NET 4.0.
Upvotes: 1
Reputation: 5333
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.
Upvotes: 0
Reputation: 25408
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.
Upvotes: -3