Fonts: Difference between revisions

From NixOS Wiki
imported>Samueldr
m Adds a note about ~/.fonts
imported>Wtok
Add section explaining how installing fonts on NixOS is done
Line 1: Line 1:
== Installing fonts on NixOS ==
NixOS has many font packages available, and you can easily search for your favourites on the [https://nixos.org/nixos/packages.html# NixOS packages site].
Despite looking like normal packages, simply adding these font packages to your <code>environment.systemPackages</code> won't make the fonts accessible to applications. To achieve that, put these packages in the <code>fonts.fonts</code> array instead.
For example:
<syntaxhighlight lang="nix">
fonts.fonts = with pkgs; [
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    fira-code
    fira-code-symbols
    mplus-outline-fonts
    dina-font
    proggyfonts
];
</syntaxhighlight>


== Troubleshooting ==
== Troubleshooting ==

Revision as of 03:27, 12 March 2018

Installing fonts on NixOS

NixOS has many font packages available, and you can easily search for your favourites on the NixOS packages site.

Despite looking like normal packages, simply adding these font packages to your environment.systemPackages won't make the fonts accessible to applications. To achieve that, put these packages in the fonts.fonts array instead.

For example:

fonts.fonts = with pkgs; [
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    fira-code
    fira-code-symbols
    mplus-outline-fonts
    dina-font
    proggyfonts
];

Troubleshooting

What font names can be used in fonts.fontconfig.defaultFonts.monospace?

Those that fontconfig will understand. This can be queried from a font file using fc-query.

$ cd /nix/var/nix/profiles/system/sw/share/X11-fonts
$ fc-query DejaVuSans.ttf | grep '^\s\+family:' | cut -d'"' -f2

Adding personal fonts to ~/.fonts doesn't work

The ~/.fonts is being deprecated upstream[1]. It already is not working with NixOS.

The new preferred location is in $XDG_DATA_HOME/fonts, which for most users will resolve to ~/.local/share/fonts[2]