Home > Software engineering >  Strange WPF font issue
Strange WPF font issue

Time:11-21

I'm seeing a difference in text/font quality between MainMenu and ContextMenu items in my desktop app. In the screenshot below, the first line was taken from a ContextMenu and the second line from a MainMenu (which arguably looks much better). The third line is from a ContextMenu with TextOptions.TextFormattingMode="Display" applied, and while this is a slight improvement on the first it's still not as good as the MainMenu.

enter image description here

I've used the "Snoop" tool to confirm that font styling is the same between the main menu and context menu (size, weight, family, etc.) so I'm assuming this is a rendering quality/clear type issue?

The font family is "Roboto" (as I'm using the "Material Design in XAML" NuGet package), and it is a .Net6 project if that makes a difference.

CodePudding user response:

I am pretty sure that the problem can be found here:

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/tree/master/MaterialDesignThemes.Wpf/Themes

It appears that there is a custom style for the Menu which uses that font, while there is no custom style for the ContextMenu which uses a different font. Probably because styling a context menu is more complex.

CodePudding user response:

It turned out to be something to do with Remote Desktop. If I work on the PC locally then the ContextMenu text is fine but if access the PC via RDP then I see the font issue described above.

A bit of a weird one, and no idea why it only affected ContextMenu fonts.

  • Related