In Silverlight 5 you may make your application look better by changing the way fonts are rendered. You make this change by applying some additional setting in your App.xaml.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!-- Control the way glyphs are generated. You can set either *Ideal* (nicer for larger fonts) or *Display* (nicer for small ones) --> <TextFormattingMode x:Key="NormalTextFormattingMode">Display</TextFormattingMode> <!-- Allows to disable text optimization - recommended setting is *Fixed* (improved readability) than *Animated* (optimized for animations) --> <TextHintingMode x:Key="NormalTextHintingMode">Fixed</TextHintingMode> <!-- Controls font antialiasing setting. You can set: *Allased* (turns off antialiasig), *ClearType*, *Grayscale* (anialiases font using grayscale), *Auto* (tries to guess the best setting for you) --> <TextRenderingMode x:Key="NormalTextRenderingMode">ClearType</TextRenderingMode> <Style TargetType="TextBlock"> <Setter Property="TextOptions.TextFormattingMode" Value="{StaticResource NormalTextFormattingMode}" /> <Setter Property="TextOptions.TextHintingMode" Value="{StaticResource NormalTextHintingMode}" /> <Setter Property="TextOptions.TextRenderingMode" Value="{StaticResource NormalTextRenderingMode}" /> </Style> |
The whole instruction regarding this topic was described here.
When using the RadRichTextBox control (part of Telerik Controls Library) you may approach an unwanted situation, where caret is displayed on the wrong place. Instead of the caret at the end of the line:
you may see something like this:
The problem here is that RadRichTextBox uses TextBlock internally to visualize the text. Setting implicit styles to them modifies the UI, but doesn’t affect the measuring system, which doesn’t support TextOptions.TextFormattingMode property.
The Telerik team is aware of the buggy situation and there is even an issue created in their backlog for the feature 🙂 They suggest a workaround, by setting that option with value = “Ideal” just for RadRdichTextBox control:
1 2 3 4 5 6 7 |
<telerik:RadRichTextBox > <telerik:RadRichTextBox.Resources> <Style TargetType="TextBlock" > <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" /> </Style> </telerik:RadRichTextBox.Resources> </telerik:RadRichTextBox> |
… and it works like a charm! 😉