Ping Services

Wednesday, May 18, 2011

How to install and convert fonts on Linux

This article will show you how to install fonts on Linux and make them available for your programs to use. The installation is quite simple but sometimes, fonts are made available in the otf format, which we will have to convert.

(Sorry for this post making it to your feed readers yesterday, I accidentally clicked on the publish button)


Firstly, you will have to open your file manager as root. You will have to press ALT-F2 and enter a command. This can be done in several ways:
1. On Ubuntu (and Ubuntu derivatives): "gksudo nautilus" or "kdesudo dolphin"
2. Other distros: "gksu nautilus" or "kdesu dolphin".
3. Fedora: Install "beesu" and use it as a command. Eg. "beesu nautilus"

I won't go into other commands, but if you don't require the commands listed above, you probably don't need to be told.
Afterwards, it is just a simple matter of moving the fonts that you would like to install to /usr/share/fonts/truetype.





However, otf fonts cannot be installed in this manner. We need to use a converter that will allow us to convert the files from otf to ttf format.

Step 1: Otf2ttf.sh
Open your text editor, paste the following inside and save it as otf2ttf.sh somewhere you can find it.
#!/usr/local/bin/fontforge
# Quick and dirty hack: converts a font to truetype (.ttf)
Print("Opening "+$1);
Open($1);
Print("Saving "+$1:r+".ttf");
Generate($1:r+".ttf");
Quit(0);

Step 2: Fontforge
Make sure that fontforge is installed through your package manager.

Step 3:
Now let's install some fonts. I will be installing the free Linux Libertine font to show you the process. Incidentally, Wikipedia uses this font for its logo.
Step 4:
After downloading the fonts that you will like to install, copy and paste otf2ttf.sh to the folder in which your fonts are saved.

Step 5:
Navigate to that folder using the terminal.

Step 6:
Run the following command to convert all otf fonts in the folder to ttf fonts.


for i in *.otf; do fontforge -script otf2ttf.sh $i; done 


Your original fonts will be preserved.

Step 7: 
Move these fonts to /usr/share/fonts/truetype




You can see that these fonts are now ready for your use.

I hope that you found this useful. I haven't tried the new Ubuntu release yet but it only seems like yesterday when Lucid was out. Who else is still using Lucid? I still am.

No comments:

Post a Comment