[Fontconfig] Re: fix for unaligned accesses

Mike FABIAN mfabian at suse.de
Tue Jan 24 02:57:14 PST 2006


Patrick Lam <plam at MIT.EDU> さんは書きました:

> Mike FABIAN wrote:
>> 
>> I think there are still problems with the normalizing of the font
>> directory names.
>> 
>> I posted a patch to this list recently to fix the problem that
>> 
>>     fc-cache /usr/share/fonts
>>     fc-cache /usr/share/fonts/
>>     cd /usr/share/fonts; fc-cache .
>> 
>> generate different cache files, but this patch had the problem that
>> it neede to call FcInitLoadConfigAndFonts () instead of
>> FcInitLoadConfig () to be able to use FcConfigNormalizeFontDir().
>> 
>> But this has the severe disadvantage that  FcInitLoadConfigAndFonts ()
>> is very expensive, therefore this is not a good solution.
>
> I don't think that's true: I think that we *can* call
> FcConfigNormalizeFontDir if we make sure to call things in the proper
> order.  I haven't had time recently to investigate this in detail, but
> hopefully next week.

Have you looked into this issue?

I still believe that the current approach is flawed because
FcInitLoadConfig () doesn't recurse through the subdirectories and
therefore doesn't initialise the list of font directories used by
FcConfigNormalizeFontDir () completely, it fills only the directories
directly mentioned in the .conf files into the list.

There is another problem:

It used to be possible to create a cache file in a directory
with

     fc-cache directory

even if this directory was not a subdirectory of a font directory
listed in a .conf file.  I think this behaviour should not be changed,
it should be possible to create a cache in /var/cache/fontconfig for
an arbitrary directory by giving it as an argument on the fc-cache
commandline.  It would be confusing if a cache is only generated if
that directory is a subdirectory of a directory listed in a .conf
file.

But that means that this directory has to be added using
FcConfigAddFontDir () in fc-cache, it will never be added
automatically no matter which init function is called (neither
FcInitLoadConfig () nor FcConfigNormalizeFontDir () will do it).

If such a directory is given on the commandline, normalizing
it by comparing with the directories in the list is impossible.

The only possibility left is to normalize it while adding it.

I.e. it would be best if the function FcConfigAddFontDir () would
normalize directories while adding them so that they appear in the
list always in a standard form.

Then we need something like realpath () again.

Takashi Iwai <tiwai at suse.de> had the idea that realpath () can be
emulated portably using chdir () and getcwd ().

I made a patch to use this idea in FcConfigAddFontDir () (patch is
attached).

Unfortunately we noticed later that this might cause problems
because chdir () is process global and therefore not thread-safe.

Maybe it is the best to implement portable version of realpath () in
fontconfig?

libiberty from binutils also implements it's own version of realpath (),
maybe that can be used.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: improve-normalization-of-font-path.patch
Type: text/x-patch
Size: 3457 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20060124/223d6686/improve-normalization-of-font-path.bin
-------------- next part --------------


-- 
Mike FABIAN   <mfabian at suse.de>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。


More information about the Fontconfig mailing list