LinuxCommandLibrary

setfont

Change the console font

TLDR

Change the terminal font

$ setfont [font].gz
copy

Change the terminal font by specifying a path
$ setfont /usr/share/kbd/[mapping]/[font.ext]
copy

Double font size
$ setfont [[-d|--double]]
copy

Reset to the default font
$ setfont
copy

SYNOPSIS

setfont [options] [fontname]

PARAMETERS

-V, --version
    Display program version information.

-h, --help
    Show a help message and exit.

-v, --verbose
    Enable verbose output during operation.

-vc, --verbose-config
    Be verbose about configuration files used.

-o , --output-map=
    Save current console character map to file.

-om , --output-unimap=
    Save current console Unicode map to file.

-ou , --output-uni-alt-map=
    Save current console Unicode alternate map to file.

-O , --output-font=
    Save current console font to file.

-C , --console=
    Apply font changes to the specified console device (e.g., /dev/tty1).

-U , --unimap=
    Load a Unicode map from file along with the font.

-M , --map=
    Load a character map from file along with the font.

-u , --uni-alt-map=
    Load a Unicode alternate map from file.

-d , --dir=
    Specify a directory to search for font files.

-L , --load-only=
    Load only the font from file, without charmap or unimap.

-w , --width=
    Set the font's character width (columns).

-h , --height=
    Set the font's character height (rows).

-c , --char-width=
    Set the character cell width.

-r , --rows=
    Set the number of text rows on the console.

-F , --default-font=
    Use file as the default font if no fontname is provided.

-A, --auto-vertical-size
    Automatically determine the vertical size of the font.

-W, --auto-hcount
    Automatically determine the horizontal character count.

-T, --test
    Test the font without actually loading it onto the console.

-e , --encoding=
    Set console encoding (obsolete for modern Unicode consoles).

-s , --size=
    Set font size, e.g., '8x16'.

-m , --map-file=
    Load a character map from map (alias for -M).

-a, --ascii
    Force ASCII-only character display (relevant for old terminfo setups).

-b, --8bit
    Force 8-bit character display (relevant for old terminfo setups).

-p, --pcf
    Load a PCF font (obsolete, most console fonts are PSF).

-t, --term
    Set terminal type (obsolete, handled by kernel).

DESCRIPTION

setfont is a command-line utility used to load a font onto the Linux console (text-mode terminal, TTY). It allows users to change the appearance of text displayed on the virtual consoles, which are typically accessed via Ctrl+Alt+F1 to Ctrl+Alt+F6. Beyond just loading font files, setfont can also load associated character maps (.map files) and Unicode maps (.unimap files) to correctly display various character sets. This is crucial for internationalization, enabling the console to display non-ASCII characters, symbols, and various scripts.

The command supports various font formats, though often console fonts are in PSF (PC Screen Font) format. While modern Linux systems primarily operate in graphical environments, setfont remains essential for system recovery, single-user mode operations, or simply for users who prefer working directly on the console. It provides flexibility in customizing the text display for readability and aesthetic preferences.

CAVEATS

setfont primarily affects the text-mode virtual consoles (TTYs) and typically has no effect on graphical environments (like X11, Wayland) or terminal emulators running within them (e.g., GNOME Terminal, Konsole).
It requires root privileges to modify console settings.
Some options, such as -e, -p, and -t, are considered obsolete in modern Linux distributions with improved Unicode support and kernel handling of terminal types.

COMMON USAGE EXAMPLE

To load a specific font, for example, the latarcyrheb-16.psfu.gz font often found in /usr/share/kbd/consolefonts/, you would use:
sudo setfont latarcyrheb-16
The .psfu.gz extension is often implied if the font is in the standard console font directory. You can specify a full path for fonts located elsewhere.

FONT LOCATIONS

Console fonts are typically stored in /usr/share/kbd/consolefonts/ or similar directories like /usr/share/consolefonts/. These directories contain .psf or .psfu.gz (gzipped PSF Unicode) files, which are the standard formats for console fonts.

HISTORY

The setfont command has been a fundamental part of the kbd (keyboard and console tools) package in Linux since its early days. Its primary role has always been to manage the display of text on the virtual consoles, adapting to evolving character encodings and font technologies. Initially, its focus was on 8-bit character sets and simple font formats. Over time, with the advent of Unicode and the need for global character support, setfont was updated to handle Unicode maps (.unimap files) to allow the console to correctly render a wider range of characters beyond the basic Latin alphabet. While its direct interactive use might be less common in graphical desktop environments, it remains a critical component for system boot-up, recovery modes, and low-level console interactions, maintaining its relevance in the Linux ecosystem for decades.

SEE ALSO

console-setup(8), kbd_mode(1), loadkeys(1), dumpkeys(1)

Copied to clipboard