[Fontconfig] How to identify all the fonts an application specifies?

Kynn Jones kynnjo at gmail.com
Tue Mar 29 01:12:24 UTC 2016


On Mon, Mar 28, 2016 at 6:41 AM, Raimund Steger <rs at mytum.de> wrote:
> On Sun, 27 Mar 2016 19:18:56 -0400
> Kynn Jones <kynnjo at gmail.com> wrote:
>> [...]
> Yes, the application constructs a pattern (FcPattern) but before it's compared to the fonts in the cache it's modified with FcConfigSubstitute and FcDefaultSubstitute.
>
> * FcConfigSubstitute(3) goes through all config files and evaluates all target=pattern rules for the pattern.
>
> * FcDefaultSubstitute(3) sets default values for some properties that are empty after config substitution.
>
> The moment your user config steps in, all rules in config files earlier than 50* will already have been evaluated; so what you're getting at that point is not entirely the same that the application put in the pattern.

That's good to know.

> Use FC_DEBUG=4 and an awk start/stop pattern:
>
> E. g. with Firefox:
>
> FC_DEBUG=4 firefox -no-remote | \
> awk '/^FcConfigSubstitute Pattern/,/^$/{pat=pat "\n" $0}
>      /^FcConfigSubstitute test pattern/{if(pat) print pat}
>      /^FcConfigSubstitute test/{pat=""}'

This gets me precisely the information I'm after.  Thank you!

> The reason why this awk drops all patterns unless /^FcConfigSubstitute test pattern/ is that FcConfigSubstitute is called twice: Once by the application (as mentioned above) and once by FcFontMatch to apply all target=font patterns to the best match. This assumes that your config has at least one test.
>
> If you want to debug the patterns *and* the best matches, the awk becomes easier for that reason:
>
> FC_DEBUG=4 firefox -no-remote | awk '/^FcConfigSubstitute Pattern/,/^$/{print $0}'

I'm sure this one will come in handy too.  (I've already had occasion
to troubleshoot matches.)

Thank you very much for your help.  I very much appreciate it.

kj


More information about the Fontconfig mailing list