diff --git a/src/fcinit.c b/src/fcinit.c index 7d2311f..693e0b7 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -69,6 +69,25 @@ FcInitLoadConfig (void) FcConfigDestroy (config); return FcInitFallbackConfig (); } + + if (config->cacheDirs && config->cacheDirs->num == 0) + { + fprintf (stderr, + "Fontconfig warning: no elements found. Check configuration.\n"); + fprintf (stderr, + "Fontconfig warning: adding %s\n", + FC_CACHEDIR); + fprintf (stderr, + "Fontconfig warning: adding ~/.fontconfig\n"); + if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR) || + !FcConfigAddCacheDir (config, (FcChar8 *) "~/.fontconfig")) + { + fprintf (stderr, + "Fontconfig error: out of memory"); + FcConfigDestroy (config); + return FcInitFallbackConfig (); + } + } return config; }