UNIX / Linux keyboard.

Fixing Font Configuration Warning Messages

XMMS audio player running on Linux or BSD Unix.

Solved: Having multiple <family> in <alias> isn't supported and may not work as expected

I started seeing a lot of these warning messages when I upgraded to the latest OpenBSD release. But I have also seen reports of this in various Linux distributions. Things work — our music starts playing, or our browser starts, or our network protocol analyzer comes up ready to capture packets, but these font warning messages are annoying.

Some troubleshooting becomes more tedious, as even more clutter is thrown into ~/.xsession-errors while programs starts. What causes these font configuration warning messages, and how can we fix the underlying problem?

The Cause

Fonts are configured through files under /etc/fonts/. The specific files and directories are:

/etc/fonts/fonts.conf

This master configuration file tells the X font server where to find the font definitions, probably in /usr/X11R6/lib/X11/fonts/ or similar.

It also works around the possible use of some outdated directives, such as deprecated mono instead of new monospace, and alternative sans and sans serif instead of sans-serif, and possibly others.

/etc/fonts/conf.d/

This directory is filled with the fontconfig configuration files that will be used.

It is usually filled with symbolic links pointing to the font configuration files. The idea is that you install a large number of fonts and then create symbolic links only to those that work.

This directory is scanned and the files named [0-9][0-9]* are used in order. That is, those files with names starting with two digits. The naming convention is:

00 through 09   Font directories
10 through 19   system rendering defaults (AA, etc)
20 through 29   font rendering options
30 through 39   family substitution
40 through 49   generic identification, map family->generic
50 through 59   alternate config file loading
60 through 69   generic aliases, map generic->family
70 through 79   select font (adjust which fonts are available)
80 through 89   match target="scan" (modify scanned patterns)
90 through 99   font synthesis 

/etc/fonts/conf.avail/

This directory holds the actual files, the complete collection of them on OpenBSD.

/usr/share/fontconfig/conf.avail/

Linux distributions may put some (or many, or most) of the font configuration files here once you install the fontconfig package and associated font packages.

The Fix

You will find that the font configuration files look like what we see here:

Here we see a list of 9 font <family> names aliased to serif. You will get eight warning messages out of this block!

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
  Mark common families with their generics so we'll get
  something reasonable
-->

<!--
  Serif faces
 -->
	<alias>
		<family>Bitstream Vera Serif</family>
		<family>DejaVu Serif</family>
		<family>Liberation Serif</family>
		<family>Times New Roman</family>
		<family>Times</family>
		<family>Nimbus Roman No9 L</family>
		<family>Luxi Serif</family>
		<family>Thorndale AMT</family>
		<family>Thorndale</family>
		<default><family>serif</family></default>
	</alias>
<!--
  Sans-serif faces
 -->
	<alias>
		<family>Bitstream Vera Sans</family>
		[...] 

Simply modify this file to look like this:

Copy and paste with the vim editor makes this fast and easy. The added code has been highlighted here.

We're just turning one alias definition of a list of nine fonts into nine short one-font aliases.

Continue this for the rest of the alias definitions in this file, and for all the font files for which you received errors.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
  Mark common families with their generics so we'll get
  something reasonable
-->

<!--
  Serif faces
 -->
	<alias>
		<family>Bitstream Vera Serif</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>DejaVu Serif</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Liberation Serif</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Times New Roman</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Times</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Nimbus Roman No9 L</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Luxi Serif</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Thorndale AMT</family>
		<default><family>serif</family></default>
	</alias>
	<alias>
		<family>Thorndale</family>
		<default><family>serif</family></default>
	</alias>
<!--
  Sans-serif faces
 -->
	<alias>
		<family>Bitstream Vera Sans</family>
		[...] 

Back to the Unix page...