DEV Community

Cover image for Using nerd font symbols and emoji with any (unpatched) font in Linux

Posted on

Using nerd font symbols and emoji with any (unpatched) font in Linux

After I read the note on this question on the Kitty terminal FAQ I started paying attention to editors, ide's and terminals that support fallback fonts.

A fallback font is a reserve typeface containing symbols for as many Unicode characters as possible. When a display system encounters a character that is not part of the repertoire of any of the other available fonts, a symbol from a fallback font is used instead. Typically, a fallback font will contain symbols representative of the various types of Unicode characters. 1

But not all editors, ide's or terminals support them. Like the terminal emulator alacritty for example.

But Linux's fontconfig package is very complete and it allows you to create font families, which I understood are virtual fonts you create in order to have the fallback mechanism manually set up.

So let's cut to the chase! First create a file in ~/.config/fontconfig called fonts.conf with the following contents:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
  <match target="font">
    <edit name="autohint" mode="assign">
      <family>JetBrains Mono</family>
      <family>Symbols Nerd Font</family>
      <family>Noto Color Emoji</family>
Enter fullscreen mode Exit fullscreen mode

The <match> tag asks for auto-hinting in order to have better looking fonts.

The <alias> tag contains the name of your virtual font my-chosen-font-family and the set of fonts that belong to it. In my case I have an unpatched (original) font, the symbols nerd font and the emoji one.

Now all you have to do is configure your apps to use it. In alacritty it would be:

    family: my-chosen-font-family
    style: Regular

    family: my-chosen-font-family
    style: Bold

    family: my-chosen-font-family
    style: Italic

    family: my-chosen-font-family
    style: Bold Italic
Enter fullscreen mode Exit fullscreen mode



Top comments (0)