[Fontconfig] Trouble forcing rescanning of font dirs
Behdad Esfahbod
behdad at behdad.org
Tue Feb 3 18:38:07 PST 2009
Hi Diego,
I committed a modified version of your patch to my tree.
Thanks,
behdad
PS. Here's the patch:
diff --git a/src/fccache.c b/src/fccache.c
index 53df860..f35304a 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -538,7 +538,13 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
- return cache;
+ {
+ if (FcCacheTimeValid (cache, dir_stat))
+ return cache;
+ FcDirCacheUnload (cache);
+ cache = NULL;
+ }
+
/*
* Lage cache files are mmap'ed, smaller cache files are read. This
* balances the system cost of mmap against per-process memory usage.
Diego Santa Cruz wrote:
> Hello,
>
>
>
> 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) )
>
> FcInitReinitialize ();
>
>
>
> 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.
>
>
>
> Sincerely,
>
>
>
> Diego
>
> --
> Diego Santa Cruz, PhD
> Technology Architect
> _________________________________
> SpinetiX S.A.
> Rue des Terreaux 17
> 1003, Lausanne, Switzerland
> T +41 21 341 15 50
> F +41 21 311 19 56
> diego.santacruz at spinetix.com
> http://www.spinetix.com
> _________________________________
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Fontconfig mailing list
> Fontconfig at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/fontconfig
More information about the Fontconfig
mailing list