lepoco / lepoco/wpfui

Cleartype not working

Open
#1,746 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Using FluentWindow stops cleartype from working
Here is an example image, on the left is non-cleartype using greyscale and cleartype is on the right of the image
Image

Even setting the WindowBackdropType to None does not fix this, however you can do the following to fix it:

public class ClearTypeFluentWindow : FluentWindow
{
    protected override void SetWindowChrome()
    {
        try
        {
            WindowChrome.SetWindowChrome(
                this,
                new WindowChrome
                {
                    CaptionHeight = 0,
                    CornerRadius = default,
                    GlassFrameThickness = new Thickness(0),
                    ResizeBorderThickness = this.ResizeMode == ResizeMode.NoResize ? default : new Thickness(4),
                    UseAeroCaptionButtons = false,
                });
        }
        catch (COMException)
        {
            // Ignored, matching WPF-UI's own SetWindowChrome.
        }
    }
}

If you look at
https://github.com/lepoco/wpfui/blob/ffebacd61058170cf63864b7d5aa730cffff848a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs#L294
you can see the comment "// 0.00001 so there's no glass frame drawn around the window, but the border is still drawn." Anything other than 0 will still call DwmExtendFrameIntoClientArea, which breaks ClearType.
At least on my version of windows the comment is out of date and actually has no effect anyway. I would imagine that it may be there to fix windows 10, maybe a call to Utilities.IsOSWindows11OrNewer could be used?

To Reproduce

Use a FluentWindow

Expected behavior

Cleartype should work if Window set to None.
It is understandable that Mica cannot render cleartype as explained in https://github.com/lepoco/wpfui/issues/177#issuecomment-1125828059

Screenshots

No response

OS version

Windows 11 25H2 26200.8875
I am using tfm net10.0-windows10.0.19041.0

.NET version

Net 10

WPF-UI NuGet version

4.3.0

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs around line 294 and inspect how WindowBackdropType None reaches DwmExtendFrameIntoClientArea. Reproduce with a FluentWindow on Windows 11 and compare ClearType with the custom SetWindowChrome example. Done means ClearType remains enabled when the backdrop is None without losing the intended window border behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.