[Fontconfig] Re: fix for unaligned accesses

Mike FABIAN mfabian at suse.de
Wed Jan 25 08:21:00 PST 2006

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

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

pat> I also think it would be really good to get the approach I started
pat> working properly, because that really *is* a canonical path to a font.
pat> chdir() won't give you a canonical path, it just gives you a path (e.g.
pat> when you have multiple mounts of a directory).

I ditched the idea of using chdir() and getcwc() and tried to get
the approach you started to work properly.

Patch attached.

I made a new function FcConfigAddFontDirSubdirs (config, dir) which
adds all sub directories of "dir" to the list of font directories in

Using this function in FcInitLoadConfig () then makes FcInitLoadConfig ()
initialize the list of font directories correctly without having
to resort to the expensive FcInitLoadConfigAndFonts () function.

My patch adds some code to check for "." and a final "/" to
FcConfigAddFontDir () to make the common cases

    fc-cache .
    fc-cache /foo/bar/

work correctly for directories outside of the trees configured in the
.conf files as well.

Maybe this is not necessary if fc-cat is improved so that it can take
a directory as an argument and "fc-cat dir" can give info for any

In that case, the checks for "." and "/" can be omitted and the
following addition to FcConfigAddFontDir () should be enough:

+    if (FcConfigNormalizeFontDir (config, d))
+        return FcTrue; /* directory has already been added */
     return FcStrSetAddFilename (config->fontDirs, d);

My patch also improves an error message in fcxml.c which just said
"out of memory" when a directory could not be added although the
reason why the directory could not be added might be something
completely different.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: improve-normalization-of-font-path-add-subdirs.patch
Type: text/x-patch
Size: 5876 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20060125/80ef4f73/improve-normalization-of-font-path-add-subdirs.bin
-------------- next part --------------

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

More information about the Fontconfig mailing list