Console Fonts: Difference between revisions

From NixOS Wiki
m Fixed an incorrect copy-pasted value
Klinger (talk | contribs)
 
(One intermediate revision by the same user not shown)
Line 20: Line 20:
</syntaxhighlight>The console fonts included in NixOS are provided by <code>pkgs.kbd</code>, which should be included by default.
</syntaxhighlight>The console fonts included in NixOS are provided by <code>pkgs.kbd</code>, which should be included by default.
[[Category:Tutorial]]
[[Category:Tutorial]]
[[Category:CLI]]
[[Category:Fonts]]
[[Category:Configuration]]

Latest revision as of 17:37, 9 December 2024

It is possible to change the fonts used by the Linux console. The common fonts used by GUI applications cannot be used in the console. Instead, special console-specific fonts must be used. NixOS includes several such console fonts - links to them can be found in /etc/static/kbd/consolefonts.

Setting console font temporarily

The command setfont <file-path> can change the console font temporarily. For example:

setfont /etc/static/kbd/consolefonts/Lat2-Terminus16.psfu.gz

The command showconsolefont will generate a grid displaying the characters in the current font.

Note that both of these commands will only work in a TTY; they will not function in a terminal emulator.

Setting console font via configuration.nix

A console font can be set permanently via the option console.font in your configuration.nix:

console.font = "Lat2-Terminus16";

In this option, use simply the filename of the font, without the path or file extensions.

Setting fonts via full path

Note: while it is possible to use the full path of a font for this option (e.g /home/user/my-font.psfu.gz), the font setting process cannot follow symlinks. So, for example, the following option would fail:

console.font = "/etc/static/kbd/consolefonts/Lat2-Terminus16.psfu.gz";

In order to use the direct path of a file found in this directory, the following would be necessary:

console.font = "${pkgs.kbd}/share/consolefonts/Lat2-Terminus16.psfu.gz";

The console fonts included in NixOS are provided by pkgs.kbd, which should be included by default.