This topic has not yet been rated - Rate this topic

TextOptions.TextHintingMode Attached Property

April 12, 2014

Gets or sets a value that indicates whether text rendering is optimized for readability or animation.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
See GetTextHintingMode, SetTextHintingMode
<frameworkElement TextOptions.TextHintingMode="Animated"/>
- or -
<frameworkElement TextOptions.TextHintingMode="Fixed"/>

Property Value

Type: System.Windows.Media.TextHintingMode
A value that indicates whether text rendering is optimized for readability or animation.

Dependency property identifier field: TextHintingModeProperty

By default, Windows Phone optimizes text for readability. Although this is usually desirable, it can have a large performance impact when you animate the scale or rotation of text. This is because changing size or rotation results in recalculating how the glyph is most legible at that font size and position – and an animation changes that size or position 60 times a second.

When animating the rotation or scale of text, you will likely get better performance by turning off this readability optimization. To turn off readability optimization on a per-element basis, set the TextOptions.TextHintingMode attached property on that element to Animated and then set it back to Fixed when the animation ends. In XAML, this could be done as part of a visual state definition in XAML for two different states, each of which set TextOptions.TextHintingMode on an object. In code, you can use the accessor method SetTextHintingMode in code and reference the animated object when the animation starts (set to Animated) and stops (set to Fixed).

Animation that applies to text is not necessarily limited to properties of text elements. The most obvious example of a text property that can benefit from Animated behavior when animated is TextElement.FontSize (or other FontSize properties on specific types). But it might also be beneficial to set Animated behavior whenever any container that contains text animates a property that affects rendering and layout. For example, if you apply a TranslateTransform to a Grid that contains text, that animation may look better if you set TextOptions.TextHintingMode to Animated on that Grid container.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.