Skip to content

Cleartype not working #1746

Description

@Joe-Fernico

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

protected virtual void SetWindowChrome()

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 #177 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions