Configuring FontConfig

FontConfig is a library used by applications for finding fonts based on their names or other properties. It is included in modern versions of most popular X servers.

A misconfigured FontConfig installation can lead to display problems in some applications — in particular Mozilla (including Firefox and Thunderbird) seems to be susceptible to them. FontConfig issues usually result in some accented characters being displayed in a different font than the rest of the text. This happens if the font used by default lacks these characters and the program has to display corresponding glyphs from other fonts.

Three "generic" fonts used by Mozilla are called sans (or sans-serif), serif and monospace. FontConfig is used to map these names to real font names. Some Linux distros use fonts from the Bitstream Vera family for this purpose. The problem is that while these fonts are pretty good quality and are available under a reasonably free license, they lack many accented characters used in some languages. Thus, replacing the mapping for sans-serif etc. so that it maps to fonts which have all the needed characters solves the problem and leads to a more uniform look of text in Mozilla.

In order to change the mapping of generic font names to real fonts, first find a good font with all commonly used characters. Hunky Fonts is a font family based on Bitstream Vera, but with many accented characters added. Another good candidate is using fonts from the Microsoft Core Fonts package (e.g. Arial, Times New Roman, Courier New). Some other fonts with many accented characters are listed in the fonts section of my software links page.

FontConfig configuration lives in /etc/fonts. In order to change the mappings for sans-serif etc., edit /etc/fonts/local.conf and find lines similar to:

<alias>
	<family>sans-serif</family>
	<prefer>
		<family>Bitstream Vera Sans</family>
	</prefer>
</alias>

Then simply replace the font name (enclosed in <family> tags) with the name of another font that contains all needed accented characters, e.g. Hunky Sans. Similar steps should be performed for serif and monospace (of course, it is recommended to actually use a serif font for serif etc.). After that, run fc-cache to re-read the configuration. You will need to be root for all the above mentioned steps.


From the homepage of Michał Kosmulski, http://michal.kosmulski.org/
Unless indicated otherwise, all content © 2004-2016 Michał Kosmulski. All rights reserved.