Adding Fonts in WSL

  1. 1. Problem
  2. 2. Solving the scaling issue
  3. 3. Solving font issue

Not using Cygwin.

Problem

The default fonts that come with WSL/Ubuntu do not work well with emacs - not suitable for long-time editing (at least for me).

There are several particular issues. The first one is with the defects with the default font DejaVu Sans Mono (This is probably personal). The second is the scale of the fonts. Finally, the anti-aliasing of the fonts is missing.

It seems that anti-aliasing is not supported with Xming. So this article will focus on solving the first two issues.

Solving the scaling issue

This problem is relatively easy. One way is to set the fontsize particularly in emacs. Another way, which I went with, is to set directly through Xming. This is simple: just add one more argument to the shortcut to the Xming executable.

1
Xming.exe [Other options] -dpi 120

Solving font issue

The list of fonts that are available to emacs can be found by,

1
(print (font-family-list))

The fonts can be tried out by,

1
(set-frame-font [FONTNAME])

However, none of them works for me. The font that worked well for me is ubuntu mono, which can be downloaded from here.

Next, installing fonts in Xming is pretty straightforward, as shown here. It would require the mkfontscale tool, which is available in the xfonts-utils from apt. Note that mkfontscale is also available in Cygwin, but I do not think it is necessary to install a heavy system like Cygwin just for installing the font.

Finally, the new font in emacs is set by

1
2
(set-face-attribute 'default nil :height [HEIGHT])
(set-face-attribute 'default nil :font [FONTNAME])