fontconfig

Find out fallback font used by fontconfig for a certain character

If you want to know which font is being used for a certain character, try this:

FC_DEBUG=4 pango-view -q -t '{character}' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1

FC_DEBUG=4 will cause fontconfig to print its attempts to match a font that contains that character. The last font listed is the one that matched. Here are some examples:

$ FC_DEBUG=4 pango-view -q -t '' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
FreeMono

$ FC_DEBUG=4 pango-view -q -t 'ളം' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
Lohit Malayalam

$ FC_DEBUG=4 pango-view -q -t 'दी' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
Lohit Hindi

You might want to take a look at pango-view’s window to make sure the font used is actually the one you were trying to figure out. To do that, drop the -q option and simply press q to quit once you’re done. You might have to tell pango-view to use sans, serif or mono fonts with the --font option. For example, in my system, I get:

$ FC_DEBUG=4 pango-view --font='sans' -t '' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
AR PL New Kai

$ FC_DEBUG=4 pango-view --font='serif' -t '' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
AR PL New Sung

$ FC_DEBUG=4 pango-view --font='mono' -t '' 2>&1 | \
    grep -o 'family: "[^"]\+' | cut -c 10- | tail -n 1
AR PL New Sung Mono

 

Advertisements
Standard

2 thoughts on “Find out fallback font used by fontconfig for a certain character

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s