The Actipro Blog

All the latest UI control development news from Actipro

SyntaxEditor for WPF to Get TextFormattingMode Support

PostBannerSyntaxEditorDevNotes

We’re excited to announce that in the next WPF Studio 2011.1 maintenance release (which will be build 541) we have updated SyntaxEditor to support “display” text formatting mode when that mode is specified in a .NET 4.0 application.

This was especially tricky to add since WPF Studio still targets .NET 3.5 where the options don’t yet exist. Smile  But through the magic of reflection and other techniques, we now will fully support the .NET 4.0 text rendering options when SyntaxEditor is used in a .NET 4.0 app.

What is a Text Formatting Mode?

The TextFormattingMode enumeration, added in .NET 4.0, provides a Display option that can be set to indicate you would like rendered text to look good on displays.  This is beneficial when rendering smaller fonts, such as 10-12pt or smaller.

The other option, Ideal, is what is used by default and in pre-.NET 4.0 apps.  Ideal is best suited for use with larger font sizes since Display mode looks blurry when large font sizes are used or the text is scaled up.

A good summary of the text formatting API updates in .NET 4.0 is given here:

http://blogs.msdn.com/b/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx

Ideal vs. Display Comparison

Let’s look at a visual comparison between TextFormattingMode.Ideal and TextFormattingMode.Display.  For these screens we’re using Consolas at 13pt, which when using the “display” setting will allow your SyntaxEditors to render exactly like the VS 2010 code editor, with the same clarity.

TextFormattingModeIdeal

Above is the default “ideal” setting, also used in pre-.NET 4.0.  It’s not really that bad looking in Consolas but you can see that some of the letters look a bit anti-aliased, especially in the quick info popup that is not using Consolas.

TextFormattingModeDisplay

Now here is where we have applied the “display” setting instead.  The Consolas editor text is a bit crisper and the IntelliPrompt popups look much better.

Dynamic Mode Switch When Zooming

We also have implemented code to automatically force “ideal” mode when zooming in, such as with Ctrl+MouseWheel.  When text is scaled up using “display” mode, it looks very blurry.  Thus our code to force “ideal” mode kicks in whenever the SyntaxEditor.ZoomLevel property goes above 100%, thereby keeping text rendering clear in any scenario.

Summary

These new features will be very beneficial to those of you who use SyntaxEditor in .NET 4.0 apps since they will improve the clarify of text in the editor for your end users.

The features are ready to go for the next WPF Studio maintenance release build 541.

Filed under: Actipro, WPF, New features

Pingbacks and trackbacks (1)+

Comments are closed