How to Install Fonts on Ubuntu

install fonts on ubuntu

In Ubuntu, you already have many fonts installed by default, but there might be a time you would want to install some additional fonts. Or maybe you want to install Microsoft fonts and Google web fonts for off-line use or for your website.

In any case, we will now see how to install fonts on Ubuntu 18.04 Linux distribution.

Downloading and unpacking the chosen font

Let’s see how we can install True Type or Open Type fonts (.ttf, .otf, .ttc) in Ubuntu 18.04.

First, we need to download the fonts we want to install. In this tutorial, we will use Hack fonts to install on our Ubuntu 18.04. We will download the fonts using cUrl with the following command:

$ curl -L -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   612    0   612    0     0   1321      0 --:--:-- --:--:-- --:--:--  1321
100  598k  100  598k    0     0  80415      0  0:00:07  0:00:07 --:--:--  164k

Next, we will unpack the file using tar:

$ tar -xzvf Hack-v3.003-ttf.tar.gz

Now we can proceed with installing our downloaded font.

Installing fonts in Ubuntu Linux

Font files are generally installed in either the system font directory on the path /usr/share/fonts/ or in a user font directory that is frequently on one of the following paths: ~/.local/share/fonts/ or /usr/local/share/fonts. We’ll use the ~/.local/share/fonts/ path in this example. If the directory does not exist, create it with the following command:

$ mkdir -p ~/.local/share/fonts

Now we will move the fonts to destination folder with mv command:

$ mv ttf/Hack-Regular.ttf ~/.local/share/fonts/Hack-Regular.ttf
$ mv ttf/Hack-Italic.ttf ~/.local/share/fonts/Hack-Italic.ttf
$ mv ttf/Hack-Bold.ttf ~/.local/share/fonts/Hack-Bold.ttf
$ mv ttf/Hack-BoldItalic.ttf ~/.local/share/fonts/Hack-BoldItalic.ttf

You can now optionally also remove the empty ttf folder and downloaded archive:

$ rmdir ttf/
$ ls
$ rm ./Hack-v3.003-ttf.tar.gz 

Clear and regenerate font cache

Finally, we need to build font information caches for apps using fontconfig for their font handling:

$ fc-cache -f -v

If you get the following error, you'll need to install the fontconfig package first:

Command 'fc-cache' not found, but can be installed with:

apt install fontconfig
Please ask your administrator.

Install the fontconfig package with the following command:

$ sudo apt-get install fontconfig
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1
The following NEW packages will be installed:
  fontconfig fontconfig-config fonts-dejavu-core libfontconfig1
0 upgraded, 4 newly installed, 0 to remove and 11 not upgraded.
Need to get 1402 kB of archives.
After this operation, 4592 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

Type Y for apt-get to proceed.

And now we can continue rebuilding the font cache:

$ fc-cache -f -v
/usr/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/vagrant/.local/share/fonts: caching, new cache contents: 4 fonts, 0 dirs
/home/vagrant/.fonts: skipping, no such directory
/var/cache/fontconfig: not cleaning unwritable cache directory
/home/vagrant/.cache/fontconfig: cleaning cache directory
/home/vagrant/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

From this terminal output, we can see that our new fonts were identified during this process.

Verify the font installation

Confirm that the fonts are installed by displaying the paths and style definitions with the fc-list command filtered on the font family name with grep:

$ fc-list | grep "Hack"
/home/vagrant/.local/share/fonts/Hack-Regular.ttf: Hack:style=Regular
/home/vagrant/.local/share/fonts/Hack-BoldItalic.ttf: Hack:style=Bold Italic
/home/vagrant/.local/share/fonts/Hack-Italic.ttf: Hack:style=Italic
/home/vagrant/.local/share/fonts/Hack-Bold.ttf: Hack:style=Bold

The fonts are now installed and ready for use.

Install fonts using Font Manager

Fonts you have downloaded can be installed by double-clicking on the font file.

Gnome font viewer

It will open it in Gnome Font Viewer. In here, you can see the option to install the font in the top right corner:

Font Viewer

You can also install Font Manager application and manage fonts that way. To install Font Manager in Ubuntu, open a terminal and use the command below:

$ sudo apt install font-manager

You can see installed fonts here and options to install new fonts, remove existing fonts, etc.

To remove Font Manager, use the command below:

$ sudo apt-get remove font-manager

Uninstall Fonts on Ubuntu Linux

We will now see how to uninstall these fonts. The process of uninstalling fonts consists of the identification of the installation paths, removal of the font binaries, and regeneration of the font cache.

First, use the fc-list command with grep to identify the paths to the installed fonts by family name:

$ fc-list | grep "Hack"
/home/vagrant/.local/share/fonts/Hack-Regular.ttf: Hack:style=Regular
/home/vagrant/.local/share/fonts/Hack-BoldItalic.ttf: Hack:style=Bold Italic
/home/vagrant/.local/share/fonts/Hack-Italic.ttf: Hack:style=Italic
/home/vagrant/.local/share/fonts/Hack-Bold.ttf: Hack:style=Bold

NOTE: Modify the grep search term to identify other font families.

Now use the rm command to remove the installed font files on the paths that you identified with the fc-list command:

$ rm -f "$HOME/.local/share/fonts/Hack-*.ttf"

Now regenerate your font cache with the following command:

$ fc-cache


In this tutorial, we have learned how to manually manage fonts using the Ubuntu Linux command line, and also manage them using GUI font tools. If you have any questions or comments, please post them below.

Leave a Comment