[Fontconfig] Re: Patch: fix for fc-cache with relative path

Mike FABIAN mfabian at suse.de
Thu Jan 12 09:13:27 PST 2006

Mike FABIAN <mfabian at suse.de> さんは書きました:

> Mike FABIAN <mfabian at suse.de> さんは書きました:
>> No new cache file has been generated:
>>     mfabian at magellan:/usr/X11R6/lib/X11/fonts/Type1$ ls /var/cache/fontconfig/
>>     d6867d8c7d183335b46263581b96fdc1.cache-2  stamp
>>     mfabian at magellan:/usr/X11R6/lib/X11/fonts/Type1$ 
>>>> -a similar problem happen when using : fc-cache /foo/bar and
>>>> fc-cache /foo/bar/ : strings used to generate md5sum are not the same,
>>>> resulting in different cache.
>>>> The attached patch fixes the issue.
>>> I've committed my patch.
>> Hmm, that problem seems to persist as well:
>> [ ... description how to reproduce ...]
> I believe I can fix this with the attached patch:

The last patch was buggy because it used FcConfigNormalizeFontDir()
but failed to include fcint.h.

I have fixed this (patch attached).

*But*, I found that my patch has the following side effect: 

Because I replaced FcInitLoadConfig () by FcInitLoadConfigAndFonts (),
"fc-cache /foo/bar" (called as root) may generate /root/.fonts.cache-2
first before creating the cache in /var/cache/fontconfig for the
requested directory:

    root at magellan:~# rm .fonts.cache-2
    root at magellan:~# rm /var/cache/fontconfig/*cache-2
    root at magellan:~# time fc-cache -v /usr/X11R6/lib/X11/fonts/Type1
    fc-cache: "/usr/X11R6/lib/X11/fonts/Type1": caching, 59 fonts, 0 dirs
    fc-cache: succeeded

    real    2m33.714s
    user    0m48.471s
    sys     0m2.532s
    root at magellan:~# ls -l --time-style=full-iso /var/cache/fontconfig/*cache-2
    -rw-r--r-- 1 root root 81920 2006-01-12 17:28:35.000000000 +0100 /var/cache/fontconfig/57fddf4aeff95a0b98650bf3f13c26fe.cache-2
    root at magellan:~# ls -l --time-style=full-iso .fonts.cache-2
    -rw------- 1 root root 4698113 2006-01-12 17:28:33.000000000 +0100 .fonts.cache-2
    root at magellan:~# 

This may cause "fc-cache" to be very slow, if neither
/root/.fonts.cache-2 nor any cache in /var/cache/fontconfig exist,
"fc-cache" will first cache *all* fonts in /root/.fonts.cache-2 (which
takes a long time) and then generate the requested cache in

I think this problem is caused because I used FcInitLoadConfigAndFonts ().

But without calling this function, FcConfigNormalizeFontDir() cannot
work right because after calling FcInitLoadConfig () the list of font
directories in the "config" structure is only the list of directories
configured in the *.conf files. Their subdirectories are still missing
in the list, they are only added when calling FcInitLoadConfigAndFonts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: normalize-path-in-fc-cache.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20060112/7d31a1c9/normalize-path-in-fc-cache.bin
-------------- next part --------------

Mike FABIAN   <mfabian at suse.de>   http://www.suse.de/~mfabian

More information about the Fontconfig mailing list