Thursday, September 9, 2010

Ubuntu 10.04: Adding Fonts from Windows and Elsewhere

It is possible to beef up the set of available fonts in Ubuntu.  The Ubuntu wiki describes several ways of doing this, including doing a search for "font" in Synaptic and downloading from there.  One package that can be downloaded that way contains Microsoft free web fonts (presently called ttf-mscorefonts-installer).  According to the wiki, fonts can also be installed manually in /home/[username]/.fonts (for the specific user) or in /usr/share/fonts (for all users).  An advantage of using the /home folder, if there is only one user of a computer, is that the fonts can then be preserved through Ubuntu reinstallations, if the /home folder is placed on a separate partition.

The wiki indicates that fonts can be simply copied, or dragged and dropped, into those folders.  There is also the occasional suggestion, however, that it is then necessary to enter a command, such as "sudo fc-cache -f -v," to enable the system to recognize them.  Following a source that I cannot presently identify, I checked System > Preferences > Appearance > Fonts > Application Font and saw that Microsoft fonts (e.g., Tahoma) were not included.  So I copied the full set of TrueType fonts (not others) from C:\Windows\Fonts (on a Windows XP machine) to /usr/share/fonts/truetype/msttcorefonts.  (Note that this was the name I gave the folder.  It contained several hundred fonts -- far more than those provided in the free msttcorefonts set that was available from Microsoft via Synaptic.)

I did not run that suggested follow-up command ("sudo fc-cache -f -v").  Moreover, I did this copying while the Fonts dialog was open.  There were also several hundred fonts in this set.  These factors, and/or others that I cannot identify, caused the system font -- the one that appears everywhere around windows and in menu commands -- to become converted to empty, unreadable rectangles (or boxes, as some people called them, or squares).  In other words, with a few simple maneuvers I was able to convert my new Ubuntu installation into something that was almost completely useless.  Readable text still appeared on the command line in a Terminal session, fortunately, and that is what ultimately helped me get out of this situation.

It seems there were several different bugs that contained or led to this problem of the letters on the screen being replaced by empty boxes, and several solutions that worked for different people.  The one that worked for me was to remove that msttcorefonts folder back to a different drive and then run three commands:

sudo dpkg-reconfigure libcairo2 libpango1.0-common
sudo fc-cache -fs
sudo update-pangox-aliases
I am not sure the third command was necessary.  Although I was focused on entering the commands properly, it seemed to me, in passing, that everything was back in shape after the second command.

Once the system was fixed, I made a backup, and then I tried again.  This time, I made sure the System > Preferences > Appearance > Font dialog was closed.  I renamed my msttcorefonts folder to be .fonts, used "sudo nautilus" to move it to /home/ray/.fonts, and then typed "sudo fc-cache -f -v" (above) to make it be recognized.  Once again, however, I had those blank squares in place of the system font.  I started to repeat the fixing procedure just described, but I didn't even have to enter the commands; merely removing the new .fonts folder from /home/ray was enough to give the system relief.  I gave up on this idea of importing the full set of Windows fonts (at least for now), and contented myself with downloading a number of font sets via Synaptic:
ttf-mscorefonts-installer, sun-java6-fonts, ttf-sil-gentium, ttf-dustin, and ttf-georgewilliams.  The attempt to bring over those hundreds of Microsoft fonts would have to await another day.

0 comments: