Adding a new TTF font to Linux

One thing that keeps me doing development on a Mac OS X is its awesome Monaco font. I saw the font first time while using Mac in my college, and I fell in love with the font ( yeah, that sounds crazy… ). I prefer Monaco over very popular terminal fonts like courier or courier new. Monaco is as crisp as courier and at the same time as sober as Helvetica.

Ok. Now to the main point.. I have been using Linux almost 10 years now. I remember from the initial days, adding a new TTF font in Linux; I always felt the steps to be too much cryptic.

After a long time today I found a seemless way to install a new TTF font.

And as Monaco is my favorite for terminal programs, I’ll show the steps using Monaco.

  1. Download a TTF font or fonts file. In case of Monaco just download it from here.
  2. Unzip, gunzip, untar, bunzip2 do whatever is required on the fonts file. For Monaco we do nothing.
  3. Copy the .ttf file to a nice place.
    $ sudo mkdir /usr/share/fonts/truetype
    $ sudo cp Monaco_Linux.ttf /usr/share/fonts/truetype/
  4. Now we need to create required files for the new fonts ( i.e. fonts.scale and fonts.dir )
    $ cd /usr/share/fonts/truetype
    $ sudo mkfontscale
    $ sudo mkfontdir
  5. This creates the required files, now we need to add the fonts to cache. One way to do it is add to cache and restart X Font Server
    $ sudo fc-cache
    $ sudo chkfontpath --add /usr/share/fonts/truetype
    $ sudo /etc/rc.d/init.d/xfs restart

    OR easy way to do it is refresh the cache forcefully. Which does not require restarting the server
    $ sudo chkfontpath --add /usr/share/fonts/truetype
    $ sudo fc-cache -fv
  6. Restart the program you want to use the font in.

You can always copy the fonts in ~/.fonts directory if you don’t have root access.

References and Resources:
http://www.gringod.com/2006/11/01/new-version-of-monaco-font/
http://vietunicode.sourceforge.net/howto/fontlinux.html
http://www.ehow.com/how_2266807_install-ttf-fonts-ubuntu.html

Tags: , ,