[Fontconfig] Trouble forcing rescanning of font dirs
Diego Santa Cruz
Diego.SantaCruz at spinetix.com
Mon Feb 2 02:47:35 PST 2009
We are using fontconfig in our project for font matching and it works
well. However at certain times we need to check if the user has
installed new fonts or removed others and make sure that fontconfig
stays current with those changes.
Thus we try to force fontconfig to validate all its caches and we do
this by doing something like
if ( ! FcConfigUptoDate (0) )
at appropriate times (i.e. just before reloading content).
Although FcConfigUptoDate() correctly reports a change when something is
added or removed from the font directories FcInitReinitialize() does not
produce the intended effect (revalidating the font directories).
We tracked a bit the code in fontconfig and when the list of fonts is
being rebuilt via FcConfigBuildFonts() the function FcDirCacheRead() is
called but with its force argument to false (which appears correct to
me). Thus the call chain to load the cache file is FcDirCacheRead() ->
FcDirCacheLoad() -> FcDirCacheProcess() -> FcDirCacheMapHelper() ->
FcDirCacheMapFd(). But when FcDirCacheMapFd() finds the cache file
already loaded through FcCacheFindByStat() it does not verify that the
font directory stat data matches the one in the cache file, happily
returning an outdated cache.
I think that FcDirCacheMapFd() should call FcCacheTimeValid() if
FcCacheFindByStat() returns a cache. Would this be the correct fix or
should I go through some other mechanism to force fontconfig to validate
all its caches?
I would greatly appreciate some feedback on this.
Diego Santa Cruz, PhD
Rue des Terreaux 17
1003, Lausanne, Switzerland
T +41 21 341 15 50
F +41 21 311 19 56
diego.santacruz at spinetix.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Fontconfig