Slow startup due to font enumeration


Hi Jules,

I have been notified by a user that JUCE apps are very slow to start up on machines with a large number of fonts. For example , when 400 MB of truetype fonts are installed, the JUCE applications typically spends more than 10 seconds running the “enumerateFaces” fonction in juce_linux_Fonts.cpp during startup , with a large disk activity. When starting the application again, it only spends 1 second in enumerateFaces because the files are already in the system disk cache. One can manually flush the disk cache with “sudo sysctl vm.drop_caches=3” , and then the startup time is 10 seconds again.

I wonder if there is an easy fix , as I’m just using the default fonts.

The non-easy fix would probably be to use the fontconfig api to enumerate the fonts, but I don’t know much about it.


Hmm… The other platforms don’t enumerate fonts on startup, but on linux it needs to examine the font list to try to figure out which faces are available (because linux isn’t as predictable as other OSes in terms of which fonts are available).

Looking at the code, I guess a better plan would be to give it a list of filenames instead of font names for its default fonts, so it doesn’t have to open all of them. I’ll see if I can get that going.


As a workaround perhaps you can embed a font in your app to skip the scan entirely?


Just had a very quick look, but it’s actually quite tricky - the font files on linux don’t seem to have sensible names, so to find e.g. “Verdana”, it is necessary to open all of them to get their real names (or at least, you need to open files until you find the one you want). Too big a job for me to look at today, will re-visit it at some point…