ZNHOO Whatever you are, be a good one!


  1. ABC
  2. Fontconfig
    1. Per-user installation
    2. System-wide installation
  3. Xorg FontPath
    1. Per-user configuration
    2. Rehash without logout
  4. Sphere - infinality
    1. infinality symlinks
  5. Practice
  6. Reference:


  1. Applications use fonts by font systems. There are two font systems, namely XLFD and XFT.
  2. X Logical Font Description (XLFD) is an old font system, originally designed for bitmap fonts. Later on, XLFD adds in support for scalable fonts like PostScript Type1, TrueType (.ttf) and even newer OpenType (.otf). XLFD fonts is usually located under /usr/share/fonts like 75dpi, 100dpi etc. An XLFD font name is a long string, as below:


    The name contains fourteen hyphen-separated fields, with each field representing a property of the font. Not all fields are required to be present. In Emacs, we can use C-x = over a character so show the XLFD name.

    XLFD is almost depcreted but still required by ancient programs like xterm, urxvt and GTK+1. To set XLFD for X, we use xfontsel, and xlsfonts.

    1. For X, we can use xset.
  3. XFT is a newer font system, supporting much more font types. depending on Fontconfig's matching feature and Freetype's font rendering feature. Freetype makes fonts (e.g. anti‑aliasing and sub‑pixel rasterization) look smooth and beautiful.

    We configure Fontconfig to use XFT /etc/fonts/fonts.conf.

  4. Application decides to use which font system. Almost all applications use XFT now, Xorg included. Emacs supports both XLFD and XFT (try M-x: describe-font).

    However, we may tune FontPath in xorg.conf covering bitmap fonts for ancient programs. Most of the time, we do not include XFT fonts in xorg.conf. To check fonts knowns to X:

    $ grep /fonts /var/log/Xorg.0.log
    $ xset q


Commands like fc-list, fc-list, fc-query, fc-match etc. can help check fonts' information.

This section demonstrates how to manully install personal fonts.

Per-user installation

~ $ mkdir -p ~/.local/share/fonts/winfonts
~ $ cd ~/.local/share/fonts/winfonts
~ $ cp /path/to/{abc.ttf,123.otf} .

~ $ fc-cache -fv ./*
~ $ mkfontscale ./ && mkfontdir ./ && xset fp rehash
  1. For manually copied fonts, we have to create the font cache with fc-cache. Font cache is to speed up font loading. Package manager (i.e. emerge) takes care of it automatically.
  2. mkfontscale and mkfontdir will create file fonts.scale and fonts.dir for XLFD fonts. xset fp rehash makes new fonts immediately available to current X sessions.

System-wide installation

To manually install fonts for the whole system is similar except that fonts are put under /usr/share/fonts/ or /opt/fonts/.

/ # mkdir /opt/fonts/winfonts
/ # chmod 755 /opt/fonts/winfonts
/ # cd /opt/fonts/winfonts
/ # cp /path/to/{abc.ttf,123.otf} ./
/ # chmod -R 644 .
/ # fc-cache -fv ./*
/ # mkfontscale ./ && mkfontdir ./

Xorg FontPath

Most of time, Fontconfig works out of box without any further configuration. To support ancient applications that use XLFD, we might need to tune "FontPath".

For Xorg to load fonts directly (as opposed to the use of a font server - XFT), the directory for your newly added font must be added with a "FontPath" entry. This entry is located in the "Files" section of Xorg configuration file. An official example is /usr/share/doc/xorg-server-1.18.4/xorg.conf.example.bz2.

Create /etc/X11/xorg.conf.d/10-fontpath.conf:

Section "Files"
# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods).
# The default path is shown here.
#    FontPath	/usr/share/fonts/misc/,/usr/share/fonts/TTF/,/usr/share/fonts/OTF/,/usr/share/fonts/Type1/,/usr/share/fonts/100dpi/,/usr/share/fonts/75dpi/

    FontPath "/usr/share/fonts/misc"
    FontPath "/usr/share/fonts/100dpi,/usr/share/fonts/75dpi"
    FontPath "/usr/share/fonts/util"
    FontPath "/usr/share/fonts/encodings"
    FontPath "/usr/share/fonts/winfonts"
  1. "FontPath" entry can be a single font path or multiple comma-separated font paths (or a combination of both). Font paths must be quoted.
  2. The default pathes (i.e. 100dpi, 75dpi etc.) are always scanned.
  3. Pathes lack fonts.scale (mkfontscale) and fonts.dir (mkfontdir) are neglected.

Per-user configuration

Settings Font Path under /etc/X11/xorg.conf.d/ are system-wide effective. For per-user setting, add

xset +fp /usr/share/fonts/dejavu/           # Prepend a custom font path to Xorg's list of known font paths

to ~/.xinitrc. Alternatively, execute it on command line.

To remove a Font Path, use -fp instead.

Rehash without logout

After the setting, we want immediate effect:

# xsetq fp rehash

Sphere - infinality

infinality USE can be enabled globally in /etc/portage/make.conf.

# echo "media-libs/freetype adobe-cff infinality" > /etc/portage/package.use/freetype
# emerge -av media-libs/freetype
# eselect fontconfig list
# eselect fontconfig enable 52-infinality.conf

fontconfig-infinality will draw in its own settings (/etc/fonts/infinality) which will interfere with the other fontconfig configuration. It's recommended to disable most of Fontconfig options while keeping 52-infinality.conf. Specially, configurations related to specific fonts can be kept like 62-croscore-*.conf* and 57-dejavu-*.conf.

You will find fontconfig (/etc/fonts/) and infinality (/etc/fonts/infinality/) has the nearly the same directory architecture. The conf.d sub-directory stores the selected symlinks, while conf.avail (or conf.src) stores all existing configurations. We use eselect which chooses and creates symbolic links under conf.d sub-directory.

Optionally, refer to reference number 3, set embeddedbitmap in /etc/fonts/infinality/infinality.conf to true.

# eselect lcdfilter list
# eselect lcdfilter set 14, set to *windows-7*
# eselect infinality list
# eselect infinality set to *win7*

Make sure lcdfilter and infinality choose the same category.


Practice from Jin Buguo Linux字体美化实战(Fontconfig配置) is outdated. However, I want to use his recommended fonts, except the Korean ones. Additionally, we need to install noto-fonts-cjk as Firefox may fallback to those fonts.

Ancient applications using XLFD refer to X11 Font Path directly. Make sure fonts.scale (by mkfontscale) and *fonts.dir (by mkfontdir) exist under each directory of font directory. Paths under /opt/fonts/ can be appended to Font Path if you'd like.


  1. Gentoo Linux on T43 (7) 中文字体
  2. 字体配置local.conf详解[带Win效果和AA效果]
  3. gentoo 下字体美化该如何设置
  4. 在Gentoo上配置Infinality
  5. Gentoo Fontconfig.