3

Is there a way to fix blurry fonts in linux GUI applications when being run from WSL (Ubuntu 18.04) using the default Windows scaling? Things I have tried so far:
With Xming:

  1. Tried disabling Windows scaling and setting it from linux side using GDK_DPI_SCALE=2.5, the problem with this is several things like context menu icons don't play nicely and are often not scaled. Without GDK_DPI_SCALE=2.5, applications are basically unusable since the text is extremely tiny.
  2. Tried installing all the fonts from C:\Windows\Fonts to C:\Program Files\Xming\fonts\TTF and running mkfontscale, couldn't make it work this way either.
  3. Tried using VcXsrv, has the same issue.

Screenshots

  • Clion:

Clion

  • Comparison between emacs (WSL) and VS Code (Windows native)

Comparison between emacs (WSL) and VS Code (Windows native)

All the resources I have looked up so far:

  1. Why are WSL GUI apps rendered with blurry fonts with Xming?: The answer here is specifically for just firefox and electron based applications.
  2. Gnome-Terminal blurry on Xming: Doesn't have anything helpful in particular either other than a suggestion to disable scaling and using something else than Xming.
  3. DPI issues running GUI programs on a 4K screen: Suggests using VcXsrv.

The main purpose of doing all this is to be able to run text editors(emacs)/IDE(Clion) from WSL. And, the reason I cannot install their windows equivalent is we develop only for linux.

Few system details:

Screen

4K (3840x2160) - 15.6"

OS

  • Windows: Windows 10 Home v1803 Build: 17134.345

  • WSL: Ubuntu 18.04 (Linux username 4.4.0-17134-Microsoft #345-Microsoft Wed Sep 19 17:47:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux)

  • Added the screenshots, thanks – lol Oct 27 '18 at 11:56
  • @Biswapriyo I am not sure what you meant by desktop environment, but the only GUI applications I'm using are emacs and CLion, every other application is terminal based. – lol Oct 27 '18 at 14:06
  • I didn't know you could full DE using WSL, however, I'm just running these two applications. Can you add it as an answer? It might worth a try. – lol Oct 27 '18 at 16:41
3

Disclaimer: The following procedure may vary with the actual hardware in system. The settings may change in your setup.

First, enable high DPI settings for the X server executable. Close any running instance of that X server. Open the folder where you have installed the X Server e.g. VcxSrv, Xming, X410 etc. Here I choose D:\MyFolder and VcxSrv as example. Open that folder, right click on vcxsrv.exe for VcxSrv or Xming.exe for Xming. Choose Properties > Compatibility tab > Change high DPI settings > Enable Override high DPI scaling > change to 'Application' (or 'System Enhanced' option). Here is the screenshot looks like after changing the settings:

Enable_Dpi_Awareness_vcxsrv

Also do the above steps for xlaunch.exe file. This change will add the following registry values:

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"D:\\MyFolder\\xlaunch.exe"="~ HIGHDPIAWARE"
"D:\\MyFolder\\vcxsrv.exe"="~ HIGHDPIAWARE"

Next, override GTK+ settings for the X11 environment. This Gnome article has in-depth view of the environment variables. GDK_SCALE will scale the windows by specific factor. GDK_DPI_SCALE will scale DPI for scale aware applications. Enable the settings with the following commands in bash (or other shell).

export GDK_SCALE=0.5
export GDK_DPI_SCALE=2

Change those value according to your system. Now execute the X server and the X11 programs. This reddit thread also helps.

  • That worked, thanks! Just to be sure I verified it with firefox too. Seems like I missed the GDK_SCALE flag. One thing that didn't work was Clion (however manually changing the font to 2.5 times the original fixed it). The rendering is quite slow though, particularly in case of firefox but that's for another question. – lol Oct 27 '18 at 19:44
  • @lol BTW, the include guard in header file shouldn't start with underscore (in VScode image). – Biswapriyo Oct 28 '18 at 8:10
  • you are correct, but this from an academic project where people didn't bother for such things. – lol Oct 28 '18 at 8:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.