September 12, 2006

Ubuntu Fonts Problem (Broken By Update?)

Posted at September 12, 2006 05:31 AM in Computers .

So I booted up my Ubuntu Linux box (running Dapper Drake) for the first time in a few weeks, and was informed that several updates were available. I've had no problems with any updates up to this point, so I installed without a second thought.

After the install, I found my emacs editor had stopped working correctly. Whenever I ran it, I saw the following errors:

Warning: Cannot convert string "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*" to type FontStruct
Warning: Cannot convert string "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1" to type FontStruct

and emacs showed a bunch of boxes instead of text. I wasn't sure if it was the updates or not, but somehow my font situation had been messed up. The System->Preferences->Fonts menu was showing all the fonts just fine, but emacs was unable to find even the most basic fonts.

It took me a lot of searching the net to figure out my problem. Emacs is an application that does not use the Gnome fonts. It uses the X Windows fonts. Available X Windows fonts can be listed via the xlsfonts command.

Running this command on my system did show some fonts, but not the standard courier and helvetica fonts I expected. As it turned out, the directories with the fonts I needed had been dropped from the X Windows font path.

I am not sure why this happened, because the xorg.conf file looks fine. In the "Files" section, the font path lines are:

FontPath "/usr/share/X11/fonts/75dpi"
FontPath "/usr/share/X11/fonts/100dpi"
FontPath "/usr/share/X11/fonts/misc"
FontPath "/usr/share/X11/fonts/Type1"
FontPath "/usr/share/X11/fonts/cyrillic"
FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
# path to defoma fonts
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"

However, when I look at my font path via the xset q command, I see only /usr/share/X11/fonts/misc in the font path. The workaround solution is to add the missing directories to the font path in my .bashrc file. This what I added to get my fonts back:

# add font paths
xset +fp /usr/share/X11/fonts/100dpi
xset +fp /usr/share/X11/fonts/75dpi
xset fp rehash

If you have seen this problem (or something very similar), please post a comment describing your experiences, workarounds, and/or solutions.

Comments

Thanks, I just had the exact problem. Although the font paths were correct, the rehash must have done the magic, emacs works again!

Posted by Joerg at September 29, 2006 09:13 AM

The font path is changed since edgy. Take a look at this for more details.

http://www.praveen.ws/journal/2006/09/30/emacs-font-problems-in-ubuntu-610-edgy-beta/

Posted by Praveen Kumar at October 3, 2006 12:22 AM

I got the same problem on debian...

I solved it only moving this two lines from the bottom to the top of the section files
FontPath "/usr/share/fonts/X11/75dpi"
FontPath "/usr/share/fonts/X11/100dpi"


Posted by Manolopm at October 10, 2006 07:37 AM

Thanks! I moved the same two lines up to the top of the block in xorg.conf and did a rehash and it's fixed :)

Posted by Adrian Amoroso at November 25, 2006 06:40 PM

... However, I find that I have to do a rehash after every boot. Shouldn't rehash permanently fix it?

Posted by Adrian Amoroso at December 11, 2006 02:07 AM
Posting of new comments has been disabled for this post.