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:
parent
253ec7609c
commit
64d7e303df
19
src/fcinit.c
19
src/fcinit.c
|
@ -69,6 +69,25 @@ FcInitLoadConfig (void)
|
||||||
FcConfigDestroy (config);
|
FcConfigDestroy (config);
|
||||||
return FcInitFallbackConfig ();
|
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;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue