[Fontconfig] Re: Bug in fc-cat with user cache
Mike FABIAN
mfabian at suse.de
Fri Jan 20 04:21:22 PST 2006
Patrick Lam <plam at MIT.EDU> さんは書きました:
> Mike FABIAN wrote:
>> Yes, I can confirm that it is still incorrect like Frederic writes.
>> What was wrong with my attached patch? I'm not sure
>> but I think something similar is necessary. if
>> (!FcDirCacheConsume (cache->fd, dir, set, config))
>> always adds the top-level directory to the list of directories
>> which is then used in FcConfigNormalizeFontDir(). For example it adds
>> the same directory /usr/X11R6/lib/X11/fonts/ many times but never
>> the subdirectories like /usr/X11R6/lib/X11/fonts/Type1/ ...
>> Replacing "dir" by "d->name" like
>> if (!FcDirCacheConsume (cache->fd, d->name, set, config))
>> seems to fix this because now the correct directory names area added
>> to the list.
>
> I don't think it should be necessary if you don't normalize the path
> in the outer fc-cat loop, because you have to treat the directory
> anyway before you can emit the cache, which should cause the proper
> directory to be added to fontDirs. Clearly the present code is
> incorrect, and I'll look at it (since I'm now back in civilization),
> but I think that we can avoid the issues involved with your patch.
>
> Also, if d->name and dir don't match, there's something wrong...
Then why is the comparison done like this in FcGlobalCacheReadDir():
if (strncmp (d->name, dir, strlen(dir)) == 0)
?
That checks whether "d->name" is a subdirectory of "dir".
If "d->name" and "dir" have to match here, the comparison
should be
if (strcmp (d->name, dir) == 0)
But then it would almost always fail, except for the top-level
directory.
Can't you reproduce the following problem?:
First delete all caches:
root at magellan:~# pwd
/root
root at magellan:~# rm -f .fonts.cache-2
root at magellan:~# rm -f /var/cache/fontconfig/*cache*
root at magellan:~#
Now call fc-match which generates the user specific cache
/root/.fonts.cache-2:
root at magellan:~# fc-match -v "Luxi Mono"
Pattern has 29 elts (size 32)
family: "Luxi Mono"(s)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
slant: 0(i)(s)
weight: 80(i)(s)
width: 100(i)(s)
size: 12(f)(s)
pixelsize: 12.5(f)(s)
spacing: 100(i)(s)
foundry: "b&h"(s)
antialias: FcTrue(w)
hintstyle: 3(i)(s)
hinting: FcTrue(s)
verticallayout: FcFalse(s)
autohint: FcTrue(w)
globaladvance: FcTrue(s)
file: "/usr/X11R6/lib/X11/fonts/truetype/luximr.ttf"(s)
index: 0(i)(s)
outline: FcTrue(s)
scalable: FcTrue(s)
dpi: 75(f)(s)
rgba: 0(i)(w)
scale: 1(f)(s)
charset: set(s)
lang: aa|af|ast|ay|bi|br|ca|ch|co|cs|da|et|eu|fj|fo|fr|fur|fy|gd|gl|gv|ho|hu|ia|id|ie|io|is|kl|lb|mg|mt|nb|nds|nn|no|oc|om|pl|rm|se|sk|sma|smj|smn|so|sq|sv|sw|tn|tr|ts|vo|wa|wen|wo|xh|yap|zu(s)
fontversion: 78643(i)(s)
fontformat: "TrueType"(s)
embeddedbitmap: FcFalse(w)
root at magellan:~#
Note that the full path to the font file listed here is correct!
But now call the fc-match once again with the same arguments:
root at magellan:~# fc-match -v "Luxi Mono"
Pattern has 29 elts (size 32)
family: "Luxi Mono"(s)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
slant: 0(i)(s)
weight: 80(i)(s)
width: 100(i)(s)
size: 12(f)(s)
pixelsize: 12.5(f)(s)
spacing: 100(i)(s)
foundry: "b&h"(s)
antialias: FcTrue(w)
hintstyle: 3(i)(s)
hinting: FcTrue(s)
verticallayout: FcFalse(s)
autohint: FcTrue(w)
globaladvance: FcTrue(s)
file: "/usr/X11R6/lib/X11/fonts/luximr.ttf"(s)
index: 0(i)(s)
outline: FcTrue(s)
scalable: FcTrue(s)
dpi: 75(f)(s)
rgba: 0(i)(w)
scale: 1(f)(s)
charset: set(s)
lang: aa|af|ast|ay|bi|br|ca|ch|co|cs|da|et|eu|fj|fo|fr|fur|fy|gd|gl|gv|ho|hu|ia|id|ie|io|is|kl|lb|mg|mt|nb|nds|nn|no|oc|om|pl|rm|se|sk|sma|smj|smn|so|sq|sv|sw|tn|tr|ts|vo|wa|wen|wo|xh|yap|zu(s)
fontversion: 78643(i)(s)
fontformat: "TrueType"(s)
embeddedbitmap: FcFalse(w)
root at magellan:~#
The full path to the font file listed now is incorrect, it lacks
the final subdirectory.
>From now on it will stay like that and all applications using
fontconfig will crash.
--
Mike FABIAN <mfabian at suse.de> http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
More information about the Fontconfig
mailing list