Say that you have no global cache file, and
a directory hierarchy:
With some TrueType fonts in /usr/share/fonts/ja.
The fonts.cache-1 directories in /usr/share/fonts
and /usr/share/fonts/ja are both out of date.
(Or, there aren't any, I think the problem will
occur then as well.)
You run a program (like fc-list) that wants the
First, FcDirScan gets run on /usr/share/fonts,
when it hits /usr/share/fonts/ja FcFileScan
calls FcGlobalCacheUpdate(), which calls
FcGlobalCacheDirAdd() and adds /usr/share/fonts/ja
to the dir.
When FcDirScan() then gets called on /usr/share/fonts
later on, it calls FcGlobalCacheScanDir(), which
sees the entry added by FcGlobalCacheDirAdd()
and says "OK, I know about that directory, it's
And the fonts in /usr/share/fonts/ja aren't found
Basic idea of fix:
* The current .fonts.cache-1 file format does not allow
distinguishing the case of:
Directory and contents in global cache
Just the directory in the global cache
However, we need this distinction, since we can
And currently both cases will result in .dir entries
for a/ and b/, but need to be treated differently.
* The .fonts.cache file format is modified to do this
by adding a ".fulldir" type to go along with the
".dir" type. ".fulldir"
* Two flags are added to the FcGlobalCacheDir structure:
have_subentries - we have the entries for the
contents of the directory, so we don't need
to scan it again if we are up-to-date.
scanned_subentries - we needed the entries for the
contents of the directory, so we should write
them back out.
(The second field perhaps should be called
referenced_subentries, since it is similar to the referenced
field, but refers to the contents, not the directory
* The change here is compatible in one direction ... it
will work with old ~/.fonts.cache-1 directory, however
older versions of fontconfig will probably think
that there are
This probably means that it needs an update to
~/.fonts.cache-2, however, I didn't want to make that
name change in the Red Hat package without it being
upstream as well.
Created attachment 8 [details] [review]
Patch adding ".fulldir"
Not to be too picky, but this isn't an enhancement, this is
a fix for a bug that makes fonts vanish from the system.
Oops, sorry for setting the priority wrong.
Created attachment 13 [details] [review]
Marks cache entries "incomplete" with 0 timestamp
The enclosed patch marks noticed-but-unscanned directories with 0 timestamp so
that they'll get scanned. It also forces a directory scan anytime the global
cache has no entries for a particular directory.
No, the previous patch is quite wrong. The actual bug was that the directory
was added to the cache when it was discovered, rather than when it was scanned. Of
course, it was *also* added when scanned, so the fix is to delete the code that
added the directory to the global cache when discovered. As the discovery adds
the directory to the list of directories, it will be scanned and added to the
cache at that point. I'll attach a patch which simply deletes the extra cache
insertion (and includes a few other fixes).
Please see if this works.
Created attachment 17 [details] [review]
Don't add directory to cache before scanning it
After testing the proposed patch here, I've committed it to the tree.
For reference ... note that the last patch on this bug had some
issues .... sometimes directories need to be in the cache even
when they aren't scanned, and a further fix went into CVS afterwards:
2003-02-13 keithp <firstname.lastname@example.org>
* fccache.c, fcdir.c, fcint.h:
Track dirs containing fonts.cache files referenced from ~/.fonts.cache file
Closing old resolved bugs