Skip to content

Find out fallback font used by fontconfig for a certain character

2013-03-10

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

FC_DEBUG=4 pango-view -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. Note that tail will only print the output once you close pango-view’s window by pressing q. Here are some examples:

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

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

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

You should take a look at pango-view’s window to make sure the font used is actually the one you were trying to figure out. You might have to tell it 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

From → fontconfig

Leave a Comment

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

%d bloggers like this: