Skip to content

Speed up font sorting

Matthias Clasen requested to merge speed-up-format-filtering into master

After installing the Noto fonts, the GTK font chooser becomes unusable.

It renders fonts with themselves, and while it has a reycling list that only creates widgets for the visible range of the font list, we end up calling FcFontSort dozens of times. And with each FcFontSort call taking 80-100ms with 4000 fonts in the configuration, this means multi-second stalls on initial show and when scrolling.

This merge request has some more or less cosmetic changes to speed things up:

  • Don't duplicate patterns needlessly
  • Don't call FcFontSort twice
  • Only filter by formats once, and keep the resulting font lists

The underlying problem remains: FcFontSort is far too slow to use interactively, with thousands of fonts. This requires fixes in fontconfig.

And then there is are some more substantial changes:

  • Call FcFontMatch and FcFontSort in a thread
  • Call FcInit in a thread
Edited by Matthias Clasen

Merge request reports