Tuesday, August 9, 2011

How to fix "FontConfig <cachedir>" errors...

If you are getting "FontConfig <cachedir>" errors every time you run a program or in your Xorg.0.log file similar to the following:

Fontconfig warning: no  elements found. Check configuration.
Fontconfig warning: adding /var/cache/fontconfig
Fontconfig warning: adding ~/.fontconfig

This is a simple fix...in fact it's telling you what to do in the warning text. The last two lines mention that you need to add those xml elements into your .fonts.conf file. It's erroring out because it doesn't really add them by itself but you can simply add them manually or run:

sed '
/<\/dir>$/{
N
s%\(</dir>\)\n*\(\s*<match\)%\1\n <cachedir>/var/cache/fontconfig</cachedir>\n <cachedir>~/\.fontconfig</cachedir>\n\2%
}' .fonts.conf