Warn (and recover) from config file without <cachedir> elements.

When updating from older fontconfig versions, if the config file
is not replaced, it will not contain <cachedir> 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.
This commit is contained in:
Keith Packard 2006-12-02 12:14:49 -08:00
parent 253ec7609c
commit 64d7e303df
1 changed files with 19 additions and 0 deletions

View File

@ -69,6 +69,25 @@ FcInitLoadConfig (void)
FcConfigDestroy (config);
return FcInitFallbackConfig ();
}
if (config->cacheDirs && config->cacheDirs->num == 0)
{
fprintf (stderr,
"Fontconfig warning: no <cachedir> elements found. Check configuration.\n");
fprintf (stderr,
"Fontconfig warning: adding <cachedir>%s</cachedir>\n",
FC_CACHEDIR);
fprintf (stderr,
"Fontconfig warning: adding <cachedir>~/.fontconfig</cachedir>\n");
if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR) ||
!FcConfigAddCacheDir (config, (FcChar8 *) "~/.fontconfig"))
{
fprintf (stderr,
"Fontconfig error: out of memory");
FcConfigDestroy (config);
return FcInitFallbackConfig ();
}
}
return config;
}