Installing and using fonts in Ubuntu

by levien on zo 25 januari 2009 // Posted in misc // under

Older versions of Ubuntu (before 8.04) used to have a built-in font-manager that could be reached by browsing font:/// in the file-manager. However, when Gnome upgraded to their new gvfs in 2008, their font manager and viewer both stopped working. In current Ubuntu-versions, at least the built-in font viewer (gnome-font-viewer) does work again. However the lack of a Gnome font-manager still leaves Ubuntu without proper font management out of the box, which is kind of annoying. Luckily in recent Ubuntu versions you can install the fontmatrix package, which gives you the excellent Fontmatrix font manager.

But even without Fontmatrix, it's really not that hard to install fonts in Ubuntu. All the hard work is handled behind the scenes by Defoma, the somewhat invisible Debian Font Manager.

Of course Ubuntu comes with lots of free typefaces, many of which are quite good. And you can get the usual boring Windows fonts (Arial, Times New Roman, etc.) by installing the msttcorefonts package. But quite often you do really need to install additional typefaces (PostScript Type 1, TrueType or OpenType) to get some work done.

If you only have one user on your system, the easiest way to install fonts is by opening the font in the file manager and clicking the Install button. This will copy the font to the .font folder in your home directory and register it with Defoma. If you need to install many fonts, simply create a .font folder in your home directory (and if you're using the file manager, don't forget to switch on View->Show Hidden Files, or you won't see the folder) and copy the font files there. To make Defoma aware of your new fonts, run fc-cache -f -v in a terminal. This will update the font-cache, so you're ready to go.

I usually prefer to install fonts system-wide, so all users can see them. To keep my custom fonts separated from the standard Ubuntu ones, I create directories in /usr/local/share/fonts and copy the font files there. Note that you need to be root to do that, so you must either do it using a file-manager instance with root privileges (gksu nautilus), or by changing the ownership of the fonts directory using sudo chown insert-username-here /usr/local/share/fonts. I find the latter option to be somewhat safer and more practical. :-) After you're done, don't forget to update the font-cache again using fc-cache -f -v.

Oddly, also the Gnome font-viewer gfontview isn't available in the repositories for some older Ubuntu versions (8.04 and 8.10). For previewing fonts that aren't installed, you can also use the fontforge font editor. For viewing installed fonts you can use gnome-specimen. You can install both through apt-get or Synaptic.

As of version 3.2, OpenOffice.org has support for OpenType fonts. This works fairly well, although there may be problems with some fonts that use obsolete Type 1 SEAC operators for accents or that have GPOS kerning tables (Issues #107831 and #107739 in OOo QA). Other applications such as Abiword, Koffice, Scribus, Inkscape and The Gimp should work just fine with OpenType fonts.

Interestingly, LaTeX (or rather XeLaTeX) can also use OpenType fonts without problems. Just install the package texlive-xetex. Now if I want use one of my favourite fonts (Futura Book), all I need to do is include the commands \usepackage{fontspec} and \setromanfont{Futura Std Book} (note that the font name is case sensitive!) in my .tex file, and run it through xelatex instead of the usual pdflatex. Read this guide for more information. If you really do need pdflatex, that's also possible but things become somewhat more complicated, as is explained here for PostScript OpenType and here for TrueType. Unfortunately the wonderful LaTeX editor Kile does not yet support XeLaTeX out-of-the-box, but this is easily fixed for now by adding a tool and altering the QuickPreview settings.

Finally, a word about the default screen-rendering of user-interface fonts in Ubuntu. Perhaps I'm old-fashioned, but I prefer to turn off antialiasing for small font sizes, mostly because the "fuzz" introduced by antialiasing also makes my head go fuzzy. ;-) If you agree, visit http://www.sharpfonts.com/ and follow the instructions. On this site you can also download the MS Tahoma font, which is the one Windows uses (or used up to XP) for its user-interface. Although that in itself is definitely not a good reason for using it, it does render superbly without antialiasing. For that reason I usually set an 8-point Tahoma as application font, desktop font and window title font in System->Preferences->Appearance->Fonts.