Fonts

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.
Resources

Fonts are a core part of the system and are necessary in order to represent text on a display.

Font installation in Gentoo is handled much like other distributions. It can be as easy as copying the font file into the proper directory. Other methods, such as fontconfig are also possible.

Home directory

When installing fonts on a local basis, each user can create a .local/share/fonts directory in their home directory. This directory can then be filled with font files:

user $mkdir -p ~/.local/share/fonts
user $cp ~/Downloads/Inconsolata.otf ~/.local/share/fonts
Note
Historically, the ~/.fonts directory was used to store fonts on a per-user basis. The modern equivalent is ~/.local/share/fonts.
Note
Fonts can also be installed in a subfolder of the ~/.local/share/fonts directory.

Check in a few applications to see if the newly copied font has been made available. A terminal emulator or an office program should work nicely for this purpose.

Globally available

System administrators (those with root privileges) can copy fonts into the system's /usr/share/fonts directory. This will make fonts available to any user on the system.

root #cp /home/larry/Downloads/Inconsolata.otf /usr/share/fonts

Console font

OpenRC

In order to use a specific font in the console, set the consolefont variable in /etc/conf.d/consolefont to the name of a file found in /usr/share/consolefonts/ (without the .psfu.gz suffix).

FILE /etc/conf.d/consolefontSetting the console font
consolefont="lat9w-16"

Next add consolefont init script to boot runlevel:

root #rc-update add consolefont boot

media-fonts/terminus-font is a good option; It has fonts with sizes from 12 to 32 pixels making it suitable for HD screens or providing an option for larger console fonts.

systemd

Configuration of the systemd virtual console is done using the /etc/vconsole.conf configuration file.

To set a specific font set the FONT to the name of a file found in /usr/share/consolefonts/ (without the .psfu.gz suffix). The FONT_MAP is set to the name of a file found in /usr/share/unimaps/ (also without any suffix).

FILE /etc/vconsole.confSetting the console font
FONT=lat9w-16
FONT_MAP=8859-15

New configuration can be reloaded by:

root #systemctl restart systemd-vconsole-setup.service
Tip
It is also possible to override the FONT and FONT_MAP using vconsole.font= and vconsole.font_map= kernel command line parameters.

GUI font

To configure fonts for use in graphical applications see the Fontconfig article.

Font installation to support viewing more scripts

Emoji and symbols

root #emerge --ask media-fonts/noto-emoji
Note
Once installed, Noto Emoji can be configured selected for use as a fallback font (used when a glyph does not exist in the selected font) for emoji symbols using the following command:
root #eselect fontconfig enable 75-noto-emoji-fallback.conf
Web browsers tend to use their own font selection logic, simply installing the package is enough.

Currently available through the GURU overlay:

root #emerge --ask media-fonts/symbola

Non-Latin scripts

Gentoo doesn't install many fonts by default; if a character needs to be displayed that the system does not have a glyph for it will be rendered using the .notdef character also known as tofu this is typically:

  • a little square which is often empty, ☐
  • a box with an X in it, ☒
  • a box with a question mark in it, ⍰
  • a box containing the unicode code point

The web browser used to view this page renders it as 􏿾.

Note
The Noto (no tofu) font family provides a single (if large) package that contains a consistent set of glyphs covering most commonly used languages.

If support for additional glyphs is required consider installing a selection of the following packages:

Language Package(s)
Bengali media-fonts/lohit-bengali media-fonts/noto
Japanese media-fonts/mikachan-font-ttf media-fonts/noto-cjk
Korean media-fonts/alee-fonts media-fonts/noto-cjk
Persian media-fonts/farsi-fonts media-fonts/noto
Tamil media-fonts/lohit-tamil media-fonts/noto
Thai media-fonts/thaifonts-scalable media-fonts/noto

Additional package considerations

media-fonts/fonts-meta (Meta package for fonts to cover most needs):

root #emerge --ask media-fonts/fonts-meta

Microsoft's TrueType media-fonts/corefonts:

root #emerge --ask media-fonts/corefonts

Configuring fonts in applications

The way programs handle fonts can be different for every program. But most applications follow a certain convention. They accept the name of the font as a variable for their font configuration. The following command will give the list of all fonts that are currently available to the user issuing it (all fonts in ~/.local/share/fonts and /usr/share/fonts).

user $fc-list
...
/usr/share/fonts/FiraCode-Medium.ttf: Fira Code,Fira Code Medium:style=Medium,Regular
...

Here, the first field after the : (Fira Code in this case) is the family of the font that should be used in the configuration of most applications.

See also

External resources