[Fontconfig] Committed mmap patch to branch
plam at MIT.EDU
Tue Aug 30 16:09:26 EST 2005
In fontconfig's CVS branch 'fc-2_4_branch', you'll find a version of
fontconfig that mmaps font information (FcPatterns and company) to and
from disk. When you run the new fc-cache executable, it will create a
'fonts.cache-2' file in each font-containing directory. Fontconfig will
then mmap in data structures from each fonts.cache-2 file and use these
fonts just like it used to.
This solution is portable across platforms: fontconfig creates a
signature from machine characteristics (i.e. the sizes of the relevant
datatypes and the endianness) and stores multiple copies of the fonts
information in each cache file.
Can't create caches in the font directories? The global per-user fonts
cache still works as it did before, except that it now uses mmapable
The only API change is to FcDirSave, which no longer takes a *dirs
argument. I suppose it could, if it had to. Data structures are not
observably different from before: there are some additional types in the
FcValue union, but they will never be used in an FcValue that is
returned to client code.
The mmap is indifferent with respect to where the patterns get loaded
into memory: when writing to disk, fontconfig allocates one chunk of
memory per directory and writes relative pointer differences within the
chunk. The pointers are reconstituted before they are passed to client
Enjoy! Please test this branch and report any problems to me. I
believe that this code is relatively solid, although I'm sure that there
are some minor omissions.
More information about the Fontconfig