Blurry fonts on using Windows default scaling with WSL GUI applications (HiDPI)
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:
- 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. WithoutGDK_DPI_SCALE=2.5
, applications are basically unusable since the text is extremely tiny. - Tried installing all the fonts from C:\Windows\Fonts to
C:\Program Files\Xming\fonts\TTF
and runningmkfontscale
, couldn't make it work this way either. - Tried using VcXsrv, has the same issue.
Screenshots
- Clion:
- Comparison between emacs (WSL) and VS Code (Windows native)
All the resources I have looked up so far:
- Why are WSL GUI apps rendered with blurry fonts with Xming?: The answer here is specifically for just firefox and electron based applications.
- 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.
- 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
)
Solution 1:
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:
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.