Blurry Text on Windows with Non-HDPI Displays (Linux is ok)

Is there any way to improve the clarity (sharpness) of text in labels and GtkEntries? It seems that Windows is more affected by this issue compared to Linux. Please refer to the outputs using the same code and system font (the default font provided by GTK) on both Linux and Windows.

When comparing Linux3.png and Windows3.png (the last images in each series), you can notice that the text on Windows appears blurry, with digits sometimes blending together with gray. This makes the text difficult to read. On high-DPI displays, everything looks much better. Also, text on linux looks fine. Gtk version: 4.14.5.

Linux1.png:
Linux1
Linux2.png:
Linux2
Linux3.png:
Linux3

Windows1.png:
Windows1
Windows2.png:
Windows2
Windows3.png:
Windows3

Hi,

On Windows, Gtk will by default use

  • the platform’s font renderer (i.e. DirectWrite or GDI)
  • the system font (i.e. “Segoe UI 9”)

But due to technical reasons, Gtk4 doesn’t support RGB subpixel aliasing, but only grayscale. This is an issue, because:

  • DirectWrite doesn’t handle grayscale subpixels as good as RGB ones
  • The Segoe font is optimized for RGB aliasing, and renders weird in grayscale

There are several options to improve rendering:

  • disable DirectWrite in Pango, like they do in msys2 (see patches)
  • use another font renderer, like fontconfig, by setting the environment variable PANGOCAIRO_BACKEND=fc
  • use another font than Segoe

I detailed some days ago my personal font config on Windows, you may want to have a look.

I applied the patch and disabled DirectWrite in Pango, as you suggested. However, in my opinion, the output doesn’t look any better after disabling DirectWrite. In fact, it seems even worse than before, and I haven’t changed the font. I’m a bit puzzled because everything looks great on better monitors. Please have a look at the attached figures. Do you have any other suggestions? Will this issue ever be resolved?

Windows2_woDW

Windows3_woDW

You can try to set PANGOCAIRO_BACKEND=fc, to use the fontconfig renderer.
That’s what GIMP uses to improve their font rendering.

The issue is known, but quite complex and currently gtk-win32 maintainers don’t have good solutions for that.

I noticed that bold system fonts are displayed properly. So I am wondering, would it be possible to increase the weight of the system font, making it slightly less than bold to differentiate? Can I adjust the application’s default font with more weighting, either through CSS or programmatically?

Yes, with css:

:root {
	font-weight: 600;
}

On windows I set font-weight to 550 for displays that have DPI less than 120. Simple solution that solves all font issues. Of course, cairo 1.18.x must be utilized…

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.