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
CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Standard

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

  1. Pingback: Fixing My Missing Degree Celsius Symbol – QSC Tech Blogs

  2. Pingback: Find out if a font contains certain characters | repolinux

Leave a reply to Nathaniel Beaver Cancel reply