Commit 64d7e303 authored by Keith Packard's avatar Keith Packard
Browse files

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.
parent 253ec760
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment