4

When I try to use Xming with WSL to run GUI programs, I see fonts with grayscale anti-aliasing, like with Firefox as you can see here:

Screenshot

This happens with every distro I've tried (Arch and Ubuntu), and it makes me want to poke my eyes out, but for the life of me I can't figure out how to fix it.

(Note: If you have a high DPI screen, the image will be blurry—you can press F12 and run this Javascript code to scale down: document.body.style.zoom = 1 / window.devicePixelRatio.)

What is the cause of this problem? Is the problem with Xming or with the distro? I've tried following all of the advice on Xming's website to no avail.

user541686
  • 23,629

1 Answers1

4

(Updated to also address VSCode)

For some programs, the solution is to just add this to ~/.config/fontconfig/fonts.conf:

<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign"><bool>true</bool></edit>
    <edit name="hinting" mode="assign"><bool>true</bool></edit>
    <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>   <!-- try hintmedium if it looks bad -->
    <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
    <edit name="rgba" mode="assign"><const>rgb</const></edit>             <!-- set to match your display -->
  </match>
</fontconfig>

For these programs, after you do this, you should get nice, smooth rendering, like I did here:

Screenshoot

However, for other programs, such as for Visual Studio Code (which uses Electron), you need to also install freetype2-cleartype. As Arch's manual explains, the initial cause of the problem is Microsoft patents preventing subpixel rendering, and that, in order to fix this, freetype2-cleartype can be installed from AUR either manually, or via the following (note that I'm skipping signature checking here to make it work for me):

yaourt --m-arg "--skippgpcheck" -S --needed freetype2-cleartype

If you don't have yaourt, you'll want to compile and install that from its AUR repo, and if when doing that you get GPG errors and the usual sudo pacman-key --refresh-keys doesn't work, you'll want to run sudo pacman-key --populate as explained here.

user541686
  • 23,629