Cleartype is broken from Fluent 1.3 to 2.0

Apr 12, 2011 at 11:29 AM

Hello,

can anyone tell me why Textboxes and RichtextBoxes doesn't show ClearType - Fonts in a RibbonWindow (Fluent 2.0) ?

Or is there something special in Fluent 2.0?

Here a simple example:

<Fluent:RibbonWindow x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
    Title="MainWindow" Height="350" Width="525"  >
    <Grid>       
        <RichTextBox Width="400" AcceptsTab="True" IsDocumentEnabled="False" FontFamily="Consolas" FontSize="14" Height="156" />    
    </Grid>
</Fluent:RibbonWindow>

Can you help me to understand this?

Best Regards

Apr 12, 2011 at 4:28 PM

I too have been having the same issue...TextBoxes and the like that had worked just fine before making the Window a RibbonWindow are now blurry.

If you find a fix, please share.

Thnx,

Aj

Oct 12, 2012 at 11:23 AM

This is really annoying! Does anyone know how to fix this?

Oct 12, 2012 at 11:46 AM

Hello,

this work's for me:

 

<Fluent:RibbonWindow x:Class="frmDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent" x:Name="moDesignerWindow"
    Title="{clsMultiLanguage  WizViewDesigner}"   Style="{StaticResource RibbonToolWindowStyle}" MinWidth=" 503" MinHeight="393" Height="393" Width="503"
                     FontFamily="Microsoft Sans Serif"  TextOptions.TextFormattingMode="Ideal" ShowInTaskbar="False"   ResizeMode="NoResize" 
                     WindowStartupLocation="CenterOwner"   >

You can set: 
TextOptions.TextFormattingMode="Ideal"

in the Window Config Content... this should solve this Problem...

 

Best Regards.

Oct 12, 2012 at 12:20 PM

Thank you! But I had to apply this to my content control and not to my ribbon window to work for the content.

Still its not 100% as clear rendered as before. I think this is an issue from the fluent framework that should be fixed.

 

I also found out that the real WPF Ribbons also had the same problems.

http://10rem.net/blog/2010/10/22/wpf-ribbon-october-release

http://10rem.net/blog/2010/06/06/wpf-and-silverlight-choose-your-fonts-and-text-rendering-options-wisely

Oct 12, 2012 at 12:58 PM

You are right, but my content  windows from the same type like the ribbon window.... the content control then get's the TextFormattingMode... 

 

Oct 15, 2012 at 3:34 PM
Edited Oct 15, 2012 at 3:40 PM

I found the devil in the details, it's in the FrameworkHelper.cs file:

private static void OnUseLayoutRoundingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    d.SetValue(UIElement.SnapsToDevicePixelsProperty, true);
#if NET35
#else
    d.SetValue(FrameworkElement.UseLayoutRoundingProperty, true);            
    TextOptions.SetTextFormattingMode(d, TextFormattingMode.Ideal);
    RenderOptions.SetClearTypeHint(d, ClearTypeHint.Enabled);
#endif
}

If you change

TextFormattingMode.Display

to

TextFormattingMode.Ideal

it will do the trick. (Also I'm pretty sure that the #if NET35 is not in the right position)

I uploaded a patch hopefully it will get integrated in the next build.

Developer
Oct 15, 2012 at 11:06 PM

Hi Staeff,

thank's for submitting your patch.

The real problem is that the FrameworkHelper overwrites the TextFormattingMode and the ClearTypeHint in some controls.

I don't know what the project owners think about this, but i think the FluentRibbon should just deliver a default value for those settings on the RibbonWindow level and leave everthing else to the default WPF inheritance.

Or we could choose the alternative and simply leave all TextOptions and RenderOptions settings as they are per default in WPF.

That way one only has to change those settings for the RibbonWindow as they are inherited by everything else.

I will ask the owners tommorrow, as i would like to know why they implemented it that way.

Besides:

Even Visual Studio uses TextFormattingMode.Display for the whole UI. The only exception in Visual Studio is the code editor, which switches from Display to Ideal when the zoom is not equal to 100%.

Oct 16, 2012 at 7:17 AM
Edited Oct 16, 2012 at 7:19 AM

Hi batzen,

Thank you for your answer. I also think leaving all in WPF defaults would be the best way. Because it displays every thing just fine as you can see below:


System.Windows.Controls.Ribbon.RibbonWindow


Normal WPF Window


Fluent.RibbonWindow (no changes)


Fluent.RibbonWindow (TextFormattingMode.Ideal)

Developer
Oct 21, 2012 at 5:47 PM

FYI: We are now leaving TextOptions as they are.