When I run fc-mach Sans, it returns DejaVuSans.ttf: "DejaVu Sans" "Book" but if it is run like fc-match "Sans " or fc-match "Sans 9" it returns unifont.ttf: "unifont" "Medium". I prefer to always use DejaVu Sans but I can't figure out why fontconfig selects unifont. Neither the global nor the local config seems to mention unifont (grep -ri unifont /etc/fonts/ ~/.fonts.conf returns nothing). Playing with LC_DEBUG didn't help me either. Is there a way to get the information why fontconfig behaves like this?

2 Answers 2


On a quick glance it looks like a genuine fontconfig bug to me, since it works properly here and I do have both DejaVu and Unifont installed:

$ fc-match Sans
DejaVuSans.ttf: "DejaVu Sans" "Book"
$ fc-match "Sans"
DejaVuSans.ttf: "DejaVu Sans" "Book"
$ fc-match "Sans "
DejaVuSans.ttf: "DejaVu Sans" "Book"
$ fc-match "Sans 9"
DejaVuSans.ttf: "DejaVu Sans" "Book"

But, on a closer look, we can see some more details. There still may be a fontconfig bug somewhere, but fc-match apparently returns a default value when it doesn't find anything. It is just the default is DejaVu on my system:

$ fc-match uni
DejaVuSans.ttf: "DejaVu Sans" "Book"
$ fc-match unifont
Unifont.ttf: "unifont" "Medium"
$ fc-match 4e5zedrkbxp
DejaVuSans.ttf: "DejaVu Sans" "Book"

The man page fc-match(1) confirms that the command does not do exact matching, but returns what it thinks are the best matches. You can see them all with -a or the more concise -s:

$ fc-match -s uni # now it also finds unifont
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
n019003l.pfb: "Nimbus Sans L" "Regular"
helvR12-ISO8859-1.pcf.gz: "Helvetica" "Regular"
FreeSans.ttf: "FreeSans" "нормален"
KanjiStrokeOrders.ttf: "KanjiStrokeOrders" "Medium"
Eadui.ttf: "Eadui" "Medium"
Unifont.ttf: "unifont" "Medium"
FreeSerif.ttf: "FreeSerif" "нормален"
cu12.pcf.gz: "ClearlyU" "Regular"
cu-pua12.pcf.gz: "ClearlyU PUA" "Regular"
10x20.pcf.gz: "Fixed" "Regular"

Upon which you can simply say "screw you" and add another search on top of it to get matching the way you expect it:

$ fc-match -s uni | grep -i uni
Unifont.ttf: "unifont" "Medium"

But, your question is about how exactly it does the matching. FcFontMatch(3) and further roughly confirm that it uses a default/configured value and definitely confirms that it first modifies the search term you passed to it. For anything even deeper, you'll have to inspect the code (start with the above mentioned function).


FontConfig matched attributes based on the "distance" from the match criteria. If you want to see what is going on behind the scenes, then set the environment variable FC_DEBUG=3 and rerun your search. This will show debugging information that might be helpful. You shouldn't need to read FontConfig code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .