From 64d7e303df441f274ee194a401dcd14dfb58af7e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 2 Dec 2006 12:14:49 -0800 Subject: [PATCH] Warn (and recover) from config file without elements. When updating from older fontconfig versions, if the config file is not replaced, it will not contain elements. Lacking these, fontconfig has no place to store cached font information and cannot operate reasonably. Add code to check and see if the loaded configuration has no cache directories, and if so, warn the user and add both the default system cache directory and the normal per-user cache directory. --- src/fcinit.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; } -- 2.39.5