[Fontconfig] commit: drastic fontconfig speedups

Stephan Kulow coolo at suse.de
Mon Nov 28 08:22:09 PST 2005

Am Montag, 28. November 2005 05:04 schrieb Keith Packard:
> I think most applications should use FcFontSetList instead so that they
> receive the set of fonts necessary to render arbitrary characters,
> instead of a single font with limited Unicode coverage. I know that
> Pango and Mozilla both use the listing function exclusively; I'm not
> sure how to improve the performance of this function though.

Unfortunately this is not true, firefox spends roughly 49% of the time
it takes to call "firefox-bin http://www.fontconfig.org" in 9 FcFontSort
calls (if you have enough fonts installed).

The FcFontSetList function you name is called by Qt though and is also
horribly expensive as it rebuilds the full list of FcPatterns according to the
FcObjectSet given using hashes to group the list. For the Qt case it's enough 
if FcFontList had a way to get _all_ fonts.

We toyed around with providing a 0 pointer to FcFontList and this kind of 
works, but as the API will be backwards compatible, but crash when the old 
library is called from new applications, it would be better if the APIs were 
different there. 

Any suggestions? I see different ways like a FcCreateAnyObjectSet() or the 
suggested 0 pointer - or changing the semantic of the empty ObjectSet (which 
had the advantage of being able to write fontconfig version agnostic 
application code: "if FcFontSetList(FcCreateObjectSet())->nfonts == 0: 

But yes, FcFontSort needs some major optimizing - and you will only gain small
parts if you adopt techniques we used for optimizing FcFontMatch. But then 
again: I think if you throw away fonts early as they share scripts already 
provided by the merged set, you could gain some more. But this indeed needs
more thinking. 

But I learned my lesson: I'll deinstall most of the fonts I installed for 
testing, 1.3 Billion instructions in firefox's FcFontSortfirefox teached 
me :)

Greetings, Stephan

More information about the Fontconfig mailing list