...making Linux just a little more fun!

<-- prev | next -->

X Fonts Display Poorly? Not Anymore

By Thomas Adam

Introduction

[ ** Although I am the author of this article, I really must acknowledge Ben, Jim and Heather for their assistance in solving this problem. Thanks, guys :) ** -- Thomas Adam ]

I recently brought a new laptop. A nice new Toshiba T1330 model. OK, so it's not the best model on the market, I'm sure. But it was all I could afford given my student budget; and anyone that is a student knows how little is provided.

So, having got the thing back home and removing something called "XP" which used some kind of weird filesystem I'd never seen before, I installed Debian Sarge. Something that a *very* kind fellow named Frank Rodolf (of TAG) had sent me down...

It installed marvellously and it was much easier and faster than perhaps SuSE was (my main distro before I switched to Debian). In under an hour, I had everything installed (including X) and was ready to launch into doing Linux Things (tm). Or so I thought... until I fired up FVWM.


The Problem

My window manager launched just fine -- no errors. I was able to open programs as I normally would (via 'update-menus') except that with some programs (GTK inparticular), I was seeing the fonts being displayed incorrectly. It was as if the edges of the fonts had been 'eaten' somehow.

I thought that was odd, and so I decided to see what might be causing it. Initially I thought it might have been a buggy video module that I had selected. Just to be sure (I was using VESA -- so there ought not to have been a problem per se) I changed it to a temporary one:

[n6tadam@laptop n6tadam]$ sudo dpkg-reconfigure xserver-xfree86

Restarted the X server, logged in..hmmm, still the same. One other thing I was beginning to notice as well was that; particularly with GTK+ applications that the font rendering was rather too large, very large. "What was going on?" I wondered.... As I had noticed two things rather odd with GTK apps (gvim was a classic example), I decided to check that my $HOME/.gtk* files were 'ok'.

Since I know absolutely nothing about how GTK+ apps use these configuration files, my safest bet was to see if these files were contributing to my large font problem was to simply rename them. Thus:

[n6tadam@laptop n6tadam]$ mv ~/.gtk-rc ~/gtk-rc.THIS_IS_HIDDEN && gvim &

Guess what....same problem :( I moved the file back again and started to think what else it could possibly be. I'd ruled out that it couldn't be a GTK+ specific problem as I had tweaked the damn file to death with still the same results each time. So, the problem therefore probably had to lie at a lower level than the configuration one...

At this point, I was getting desparate. What was I going to do? I couldn't really do any work whatsoever...at least, not the kind of work I needed to (Lyx stuff) -- none of the fonts worked...So I did what any sane person would do. I e-mailed The Answer Gang. As usual, I got replies, all of which were very helpful. It feels odd for me e-mailing TAG -- usually I am the one answering questions; not asking them :)

One of the replies I got back though got me thinking. What is the job of X? Well, very loosely put it is a layer that provides protocols for the Window Manager to use so that various things can be set (position of window etc.). Is it therefore up to X to provide the fonts? No -- that is at the programming level....

... not quite. Some distributions (RH, Mandrake) run a program called "xfs": "X Font Server". It provides a means of sharing fonts across a network to which many hosts connect to the server. Great, but is that of any use to me? No..so why not get rid of it? Indeed, am I even using one?

[n6tadam@laptop n6tadam]$ /etc/init.d/xfs status
xfs is running.

Bah -- so I *do* have one. Could that be part of my problem? One of the methods that I have learnt in solving problem is to try and break it down. Diagnosis of computer problems therefore should be no different, excpet that I employ a technique I like to call: abstract de-layering. That is, remove all the non-essential layers so that you are left with the minimum number of possible conflicting processes.

You may well be thinking though that if I were to kill the xfs that my X server wouldn't work anymore? Well that is what I thought until I remembered that actually there is a 'fallback' method -- the X server configuration file itself...


The Solution

So...how did I solve this in the end? Firstly I had to find a way of killing xfs permenantly -- I just didn't need it. All it was doing was adding another layer of complexity that I don't need. In debian there's a really useful script: "update-rc.d". Thus:

[n6tadam@laptop n6tadam]$ sudo update-rc.d -f /etc/init.d/xfs remove

Bye-bye, xfs. Of course there are other ways of doing this. You could do something like edit the file so that you include the following after the she-bang line:

----------------------

#!/bin/bash 

NO_XFS = 1

[ $NO_XFS = "1" ] && {
  #tell syslogd we don't want this anymore...

  logger "Not starting XFS: you said not to...."
  exit 0
} || {
  #rest of script as written follows....
}

----------------------

But the question still remains, how are the fonts displayed if there is no font server running? By looking at X's configuration file (/etc/X11/XF86Config-4) I found the following section:

----------------------

Section "Files"
    FontPath	"unix/:7100"			# local font server
    # if the local font server has problems, we can fall back on these
    FontPath	"/usr/lib/X11/fonts/misc"
    FontPath	"/usr/lib/X11/fonts/cyrillic"
    FontPath	"/usr/lib/X11/fonts/100dpi"
    FontPath	"/usr/lib/X11/fonts/75dpi"
    FontPath	"/usr/lib/X11/fonts/Type1"
    FontPath	"/usr/lib/X11/fonts/Speedo"
    FontPath	"/usr/lib/X11/fonts/100dpi"
    FontPath	"/usr/lib/X11/fonts/75dpi"
EndSection

----------------------

Excellent! As there was no font server running then we were using the font paths listed above. One important thing to note though is that the ORDER that the fonts are listed, is the order that the fonts are searched for.. The keyword here though is "dpi" -- dots per square inch.

All I did was to change the values round in the listing so that 75 came before 100, hence the list now looked like the following:

----------------------

Section "Files"
    ###FontPath	"unix/:7100"			# local font server
    # if the local font server has problems, we can fall back on these
    FontPath	"/usr/lib/X11/fonts/misc"
    FontPath	"/usr/lib/X11/fonts/cyrillic"
    FontPath	"/usr/lib/X11/fonts/75dpi"
    FontPath	"/usr/lib/X11/fonts/100dpi"
    FontPath	"/usr/lib/X11/fonts/Type1"
    FontPath	"/usr/lib/X11/fonts/Speedo"
    FontPath	"/usr/lib/X11/fonts/100dpi"
    FontPath	"/usr/lib/X11/fonts/75dpi"
EndSection

----------------------

Now when I restarted X, it was normal. Problem solved. One interesting thing to note though is that commenting out the "unix/:7100" line above actually makes X start a little faster. I am still a little puzzled as to why xfs/X didn't talk to eachother -- what it is that caused my weird font problems in the first place.

The lesson to really be learnt here though is solving a problem such as this can be done by removing all the layers such that what you are left with is a non-conflicting layer that you can use to solve your problems cleanly.

 


picture I write the recently-revived series "The Linux Weekend Mechanic", which was started by John Fisk (the founder of Linux Gazette) in 1996 and continued until 1998. I'm also a member of The Answer Gang.

I was born in Hammersmith (London UK) in 1983. When I was 13, I moved to the sleepy, thatched roofed, village of East Chaldon in the county of Dorset. I am very near the coast (at Lulworth Cove) which is where I used to work.

I first got interested in Linux in 1996 having seen a review of it in a magazine (Slackware 2.0). I was fed up with the instability that the then-new operating system Win95 had and so I decided to give it a go. Slackware 2.0 was great. I have been a massive Linux enthusiast ever since. I ended up with running SuSE on both my desktop and laptop computers.

While at school (The Purbeck School, Wareham in Dorset), I was actively involved in setting up two Linux proxy servers (each running Squid and SquidGuard). I also set up numerous BASH scripts which allowed web-based filtering to be done via e-mail, so that when an e-mail was received, the contents of it were added to the filter file. (Good old BASH -- I love it)

I am now 18 and studying at University (Southampton Institute, UK), on a course called HND Business Information Technology (BIT). So far, it's great.

Other hobbies include reading. I especially enjoy reading plays (Henrik Ibsen, Chekhov, George Bernard Shaw), and I also enjoy literature (Edgar Allan Poe, Charles Dickens, Jane Austin to name but a few).

I enjoy walking, and often go on holiday to the Lake District, to a place called Keswick. There are numerous "mountains", of which "Great Gable" is my most favourite.

I am also a keen musician. I play the piano in my spare time.

I listen to a variety of music. I enjoy listening to Rock (My favourite band is "Pavement" (lead singer: Stephen Malkmus). I also have a passion for 1960's psychedelic music (I hope to purchase a copy of "Nuggets" reeeeaaall soon).

Copyright © 2003, Thomas Adam. Released under the Open Publication license unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 96 of Linux Gazette, November 2003

<-- prev | next -->
Tux