[Fontconfig] mmaping FcInit

Owen Taylor otaylor at redhat.com
Tue Mar 22 00:03:59 EST 2005


On Mon, 2005-03-21 at 01:01 -0500, Patrick Lam wrote:
> Hi.
> 
> I've been hacking on fontconfig a bit to make it possible to mmap the 
> FcInit and related data structures.  There is some discussion at
> 
> http://bugzilla.gnome.org/show_bug.cgi?id=169345
> 
> In short, I think that one would need to replace pointers with array 
> indices; to do otherwise seems to be asking for trouble.  I've started a 
> patch that does this; my current patch is available at
> 
> http://plam.csail.mit.edu/~plam/tmp/fontconfig-strings-to-indices.diff
> 
> I'm also willing to replace FcPatternIndex with a void * datatype that 
> would be cast to ints when needed; this would avoid breaking current 
> APIs but is less aesthetically pleasing.
> 
> Does this seem to be a promising approach, and is something like this 
> commitable when complete?

The fontconfig caches live in the font directories, which may be
shared between machines with different architectures. For that reason,
even if you remove pointers, you can't simply put a structure into
the file... the endianess and structure packing may differ between
machines.

Rather, you need to a design a binary file format that can referenced
by a FcPattern. The icon cache format that GTK+ uses is an example of
this approach.

http://lists.freedesktop.org/archives/xdg/2004-October/005140.html

To deal with dynamically allocated patterns, you might have:
 
 struct FcPattern {
   int refcount;
   FcPatternStorage storage; /* dynamic, static */

   union {
     FcPatternDynamic *dynamic;
     FcPatternStatic *static;
   } u;
 };

You might also want to think about the ability to put hash-table indices
into the mmap'ed file ... fontconfig programs can spend
a lot of time scanning through a large list of patterns linearly
to find a matching family name.

Regards,
						Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20050321/3f346af4/attachment.pgp


More information about the Fontconfig mailing list