Linux – How does Linux manage fonts

fontslinuxxorg

When I used Windows (a very very long time ago!), and Mac OS X, there was always a central "repository" of fonts shared and accessed by the OS and all programs (the font folder in Windows, and Font Book in Mac OS X).

How are fonts managed in Linux? Is there also a central store for fonts that all programs (the shell with no X, with X, window managers, other GUI software) can use? Or are fonts managed separately? What can I do to efficiently and easily manage my fonts in Linux?

Best Answer

There are two mechanisms for fonts in X land: server-side and client-side.

The traditional way to render fonts is for the client to tell the server “render foo at position (x,y) in font F” (where a font specification includes a face, size, encoding and other attributes). Either the X server itself, or a specialized program called a font server, opens the font file to build the description of each glyph. The fonts can be bitmap or vector fonts, but the vector fonts are converted to bitmaps before rendering.

Most modern programs use client-side font rendering, often through xft and fontconfig. A new mechanism was needed because the server-side font rendering didn't support anti-aliasing.

Outside X (i.e. on a VGA console), there are VGA fonts, which are bitmap fonts of specific sizes. But compared to X11, no one uses the VGA console, so not much effort is spent on them.

In practice, you'll want to configure fonts in two ways:

  • For older-style programs: the font directories are listed via FontPath directives in xorg.conf and can be manipulated with xset fp commands by the user running X. If you install new fonts, you may need to run mkfontdir.
  • For newer-style programs, including all Gtk (Gnome, etc.) and Qt (KDE, etc.) programs: fonts are in the directories indicated by <dir> directives in /etc/fonts/fonts.conf, ~/.fonts.conf and a few other places. See the fontconfig documentation for more information. If you install new fonts, you may need to run fc-cache.
Related Question