Tuesday, June 6, 2017

Installing fonts on a linux distribution

Have you ever wondered how to install fonts on a Linux distribution.  In this blog post I'll be talking about the general process of installing fonts on Linux and more specifically on Ubuntu.

The process of installing fonts and using them broadly comprises of 2 steps:
1) Placing the font file in the appropriate directory.
2) Rebuilding the font cache so that the system can use the new fonts you installed. This is typically done with the "fc-cache" command.

Fonts can be installed at two different levels:
1) System wide: This makes the font available to all users on your Linux System. This requires root privileges but has the advantage of system wide font availability.
2) Per user: This is by far the easiest safest method. It does not require root privileges but makes the newly installed fonts available only to that specific logged in user.

As an example I will demonstrate installing of fonts on Ubuntu 16.04 (this should work on older ubuntu systems too it was tested on Ubuntu 14).
 
1) Installing fonts on Ubuntu system wide:
 -> Login to a root shell

 -> Create a sub folder in directory '/usr/share/<font-type>/'.

     Ubuntu splits different font types into their own individual directories (so for instance if a font is a truetype font it would go into '/usr/share/truetype/'.

    Assuming our font is a truetype font we create a sub folder called 'customFonts' inside '/usr/share/truetype/' and save your font there.

 -> Update the font cache. Run 'fc-cache'.

 -> your done

2) Installing fonts on an Ubuntu system per user:
 -> Open a regular shell as a logged in user.

 -> check if a folder "~/.fonts" exists otherwise make it. Note: here "~" is a shortcut for you homedirectory. If you username is 'foo' then "~" typically expands to '/home/foo'.

 -> install your font there (you can create a sub folder and organize your fonts however you like)

 -> Update the font cache. Run 'fc-cache'.

 -> your done

Now just reopen any program where you wish to use the font and try looking for your font. You should see the font in the list of available fonts.

No comments:

Post a Comment