1. Introduction

When looking for the installed fonts on a Linux system, we can check directories like /usr/share/fonts, /usr/local/share/fonts, and ~/.local/share/fonts. But sifting through each directory could be tiring and inefficient.

In this tutorial, we’ll talk about how to find installed fonts from the command line using fc-list and fc-match.

2. Finding Fonts Using fc-list

fc-list is the foremost way to find fonts from the command line. It comes alongside the fontconfig library. So, to use fc-list, we must install fontconfig.

We can install fontconfig on Debian-based distros using apt:

$ sudo apt update && sudo apt install fontconfig -y

Then on RHEL-based distros, we can use dnf:

$ sudo dnf install fontconfig

With fontconfig installed, running fc-list shows all fonts installed on the system:

$ fc-list
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/home/ubuntu/.local/share/fonts/Kanit-Regular.ttf: Kanit:style=Regular
...truncated...

2.1. Using fc-list With Font Properties

We can make the output of the fc-list command specific by using the font properties stated in /usr/share/doc/fontconfig/fontconfig-user.txt or /usr/share/doc/fontconfig-[version]/fontconfig-user.txt. Some of those properties include family, weight, and lang.

Using a colon notation and adding family allows us to display only the font families:

$ fc-list : family
Kanit,Kanit Black
Kanit,Kanit Medium
DejaVu Sans Mono
...truncated...

Leaving no space between the colon symbol and family (or any other property) will give us a verbose output:

$ fc-list :family
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/home/ubuntu/.local/share/fonts/Kanit-Regular.ttf: Kanit:style=Regular
...truncated...

The output includes the path to the font files. So, this could be helpful when searching for the location of our font files.

When searching for a specific family, we’ll pass a value to family and leave no space between the colon and family. The same syntax applies when using other fc-list properties.

Let’s search for fonts of the Kanit family:

$ fc-list :family=Kanit
/home/ubuntu/.local/share/fonts/Kanit-Regular.ttf: Kanit:style=Regular
/home/ubuntu/.local/share/fonts/Kanit-ExtraBoldItalic.ttf: Kanit,Kanit ExtraBold:style=ExtraBold Italic,Italic
...truncated...

Similarly, we can check for fonts whose weights are 80:

$ fc-list :weight=80
/usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
/usr/share/fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
...truncated...

We can also check for fonts that support English language (en):

$ fc-list :lang=en
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/home/ubuntu/.local/share/fonts/Kanit-Regular.ttf: Kanit:style=Regular
...truncated...

fc-list specifies languages following the ISO 639 language codes. So, we can check for fonts that support other languages by using their corresponding code.

To display the font families and all the languages they support, we will use the lang and family together:

$ fc-list : family lang
Kanit,Kanit Thin:lang=aa|af|ast|ay|az-az|...
DejaVu Sans Mono:lang=aa|af|ar|ast|av|...
...truncated...

Similarly, we can display font families and their font styles:

$ fc-list : family style
Kanit,Kanit ExtraBold:style=ExtraBold Italic,Italic
...truncated...
DejaVu Serif:style=Bold

2.2. Using Pipe and Other Commands With fc-list

We can sort the output of the fc-list command using pipe and sort:

$ fc-list : family | sort
DejaVu Sans
DejaVu Sans Mono
DejaVu Serif
Kanit
Kanit,Kanit Black
Kanit,Kanit ExtraBold
Kanit,Kanit ExtraLight
...truncated...

We can also find fonts that match a pattern using pipe and grep.

Let’s test this out by listing only Kanit fonts:

$ fc-list | grep Kanit
/home/ubuntu/.local/share/fonts/Kanit-Regular.ttf: Kanit:style=Regular
/home/ubuntu/.local/share/fonts/Kanit-ExtraBoldItalic.ttf: Kanit,Kanit ExtraBold:style=ExtraBold Italic,Italic
...truncated...

3. Finding Fonts Using fc-match

Like fc-listfc-match is part of the fontconfig library. It tries to match the installed font(s) most suitable for the pattern passed to it. However, when no pattern is passed to it, it returns a default font.

If we want to find the best monospace font, we can run:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

We can also get a list of matches sorted in order of suitability using the -s flag:

$ fc-match -s monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
...truncated...
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"

Using the -a flag, we can get a sorted match of all installed fonts (from suitable to unsuitable):

$ fc-match -a monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
...truncated...
Kanit-ExtraBoldItalic.ttf: "Kanit" "ExtraBold Italic"
Kanit-BlackItalic.ttf: "Kanit" "Black Italic"

Like fc-list, the fc-match command uses the colon symbol and font properties:

$ fc-match -s monospace : family
DejaVu Sans Mono
...truncated...
Kanit

4. Conclusion

In this article, we discussed how to find installed fonts from the Linux command line using fc-list and fc-match. We talked about various options we can use with each command and how to pipe other commands with them.

While we formatted the output of the commands using the colon notation and font properties, we could have also done the same thing using the -f or –format option.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.