Is Beauty Only Pixel Deep?, Part 2

Fonts at your service.

Welcome back, everyone, to another installment of the SysAdmin's Corner, where knowledge and discovery are keywords and mysticism and impossible are not. It is time once again to pull back the curtain from Linux fonts and have a nice long chat with the gentleman at the controls. Judging from some of the responses I received from my last column, it seems that fonts are a nightmare to many (and I can't say I blame you). Nevertheless, it's time to put away fear and learn to enjoy your font experience.

As many of you already know, I firmly believe in learning by doing, by trying out things and seeing what happens when you type this command or that one. On that note, I'm going to have you play with your fonts. I'm going to have you try some things here, some of which may wind up producing some strange-looking results when it comes to your X display's fonts. I'm not trying to scare you, I simply want to make sure you back up your files before you start.

One of the questions that came up repeatedly was that of the font server, specifically xfs. Why would you want to use xfs when XFree86 4.X already knows how to deal with TrueType fonts? I agree that it seems to be an overly complicated thing to do, but remember Linux's server roots (so to speak). The idea is that you can run a font server on one machine in your office and have all the other Linux clients take advantage of its resources. Why? Because each machine then uses the same fonts, thus providing a consistent environment. You might remember that xfs, the X font server, runs on port 7100 by default. That's what this line in your XF86Config-4 file is all about.

     FontPath "unix/:7100"

As you might have guessed by the fact that a port is specified, it is possible to run the font server from another port. In fact, you can run multiple font servers, each with its own configuration. In the following example, I started a second instance of xfs, this one running on port 7101 as opposed to the default 7100.

     xfs -config /etc/X11/fs/configtest -port 7101

Yes, I added something else to the command. That -config parameter tells the program to read its information from a different config file since I don't really want to muck up my original when I'm experimenting. In this case, the file is called configtest, and I could put it in any directory that amuses me. If you'll remember from the first part of this series, xfs uses a file called config, which can be found in /etc/X11/fs or /usr/X11R6/lib/X11/fs depending on your system. By specifying a second file, we can tweak and experiment at will.

Using the xlsfonts command, you were able to get a list of all the fonts on your system. You can also get that list with a query to the font server directly by typing fslsfonts -server unix/:7100.

Depending on your Linux distribution and your installation of X, this may or may not work. For instance, on my notebook computer (which runs Red Hat 7.2), the X font server does not allow TCP connections by default. This is done for security, but it does kind of negate the advantage I spoke of a few paragraphs back. That setting is controlled with the following line from your fs/config file.

    no-listen = tcp

Just delete the tcp from the above line, save your changes, then stop and start the font server. Now you should be able to use the fslsfonts command without a hitch. In fact, you even can use it to query your system remotely or another system altogether. For instance, I can get a list of all the fonts served by my main development machine (scidev) by using the command fslsfonts scidev:7100.

Before we move on to the next step, I want to show you how you can start a second X session on your system without touching the one you are currently using. Your X session is most likely running on virtual terminal 7. That's because your virtual terminals from 1 to 6 are busy providing text logins for additional sessions. You can jump out of your current session by typing Ctrl-Alt-F1, and get back in by typing Ctrl-Alt-F7. Give it a try.

Back safe and sound? Great. Now go to your second (or third or fourth) terminal session and login to a test account. Since I do crazy things like this all the time, I create a handful of additional logins, test users so that my own work environment remains somewhat stable. Using an alternate login, type this command at the shell prompt:

     startx -- :1

A complete second X session will start on your system, running on virtual terminal 8. To switch to your first session, you can use Ctrl-Alt-F7; Ctrl-Alt-F8 will take you back to your second session.

We'll use same principle for the X server itself. By default, it uses a file called XF86Config (or XF86Config-4). What I do is take a copy of that file and bring it into a work directory. I called mine Xperiment.

     cd $HOME/fontplay
     cp /etc/X11/XF86Config-4 Xperiment

Open your new file and look for the FontPath line. Then, change the font server from port 7100 to port 7101.

     FontPath "unix/:7101"

Now, let's start our play X session to use the new config file and the new X server.

     startx -- :1 -xf86config $HOME/tmp/Xperiment

What you have now is a separate xfs environment to play with, one that doesn't affect your current running session. You can now safely remove fonts from the catalogue (as defined in your new config file), change the load order and so on. The order, by the way, does make a difference. Look at the top of your xfs config file, and you'll see something that looks like this:

     catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,

Before you change anything, start up Netscape or the GIMP or anything that uses native X fonts. The reason I mention this is that various desktop environments (such as KDE) control their own fonts for their own applications. Unfortunately, merely running KDE and having all your fonts nicely defined doesn't mean that the GIMP necessarily will use those fonts. That said, once you've fired up the GIMP, you should get something that looks like the image below.

Now go back into your xfs config file and swap the 75dpi line at the top with the 100dpi line. Save your changes, stop and restart xfs. Then restart your desktop and get the GIMP rolling again. You should see something that looks this image:

Note that while the KDE desktop fonts look the same (the window title bar where it says The GIMP), the menu fonts (where it says File, Xtns, Help) are much larger. Some of you will be saying, "Yes, but you can change the dpi setting of your X session with a command-line option", and you are correct. What I wanted to demonstrate here is that the order of the font list matters. When the system calls for a 12 pt. regular Times font, it grabs the first one that it finds and that may not be what you want. Here's something else to try. Notice that your FontPath list includes 75dpi, 100dpi and miscellaneous fonts in both a regular version and an unscaled version.


Try putting the unscaled fonts at the top of the list instead of their scaled counterparts; you may be pleasantly surprised. In fact, consider removing the scaled fonts from the list entirely. Stop and start your font server on port 7101, then launch X. When you are happy with the results, you can migrate those changes to your real xfs configuration file.

That pretty much covers my allocation of electrons for now, so I am going to pause here. Next time around, we'll concentrate specifically on TrueType fonts. I'll tell you where you can get them and how to work with them. I may even have to mention that other OS and square away a few things. In the meantime, remember that beauty is more than pixel deep.

Marcel Gagné's book, Linux System Administration; A User's Guide (ISBN 0-201-71934-7, Addison Wesley) is in stores now (including your favorite on-line vendor). You can download a free excerpt from his web site at



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: using Xfs

Anonymous's picture

Hey, I do! Rather than going through all the bs to enact the Font Deuglification Howto on several machines, I point the other X terminals to my machine (where all the cool fonts live) and then default to whatever Redhat puts in their configurations. It's a great patch, and if I'm off installing new hardware or messing with my machine, it's still able to run, albiet not quite as pretty.

These days people are using fractions of a Gig of ram and running P3 machines and faster...xfs is a tiny TINY hit to my resources, and it makes sense to spread the wealth around without going to all the extra trouble.

To combat real resource hogging, I got rid of Netscape and Java...even on "UT breaks" during the day when I stop what I'm doing (without closing anything) and go kill things, I never see more than 512M used. I don't know what I'd do with a full Gig if I still had it installed!

Don't be too hard on the guy; you and I might be old hands at this, but when people take the time to teach newbies, it's better for everyone. I wish I had the time and/or opportunity to do it, myself.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

All these discussions will soon be obsolete.

If you follow the work done on XFree, you'll know that the problems with fonts are well known. A solution has been launched since last year. Since CVS after 4.2.0, XFree now use fontconfig, which replaces all the ancient font system, which was mostly poor hacks.

The only problem now, is for TrollTech to adapt their qt lib and the Gnome guys to adapt their pango lib, so that they can work with fontconfig.

However, they do not seem to do anything about it right now...

Re: Is Beauty Only Pixel Deep?

Anonymous's picture

The fact that an article, or in this case, a series of articles are needed to explain how to make fonts look good in Linux indicate that there is a real problem with the current system's useability! I love Linux. I am known as the Linux zealot at the office. However, this is one thing that really needs to be fixed. Like it or not, Linux is becoming more mainstream. I consider myself to be a rather advanced Linux user and even I am intimedated by XFree86. When will fonts just work "out of the box" without all of this extra crap to get it working? I know KDE has everything working, but Netscape and the Gimp always look like crap on my system, basically because I'm too lazy to spend a couple of hours reading documentation on how to fix it. I do have a life and plenty of other things to do!!! Hopefully someone will step up to the plate and fix this problem once and for all! Until then, Linux on the desktop will continue to be a distant dream.

-- tale


Anonymous's picture

Surely all the old server-side font stuff is obsoleted by the much better designed Xft/XRender combo?

Personally, I deliberately cut my legacy 1-bit fonts FontPath down to almost nothing and

just use Xft/Xrender .

Re: Fonts and the common guy

Anonymous's picture

All said and done, if there is a solution to getting Linux fonts to look great, the packaging Siegfrieds and Roys should do it and fast. I don't care if it is XFS or 75 dpi or whatever... All I want is nice fonts... everywhere! Just like there are nice icons for KDE, Gnome etc. that people are developing, let us have a nice effort for getting the font problem fixed.

Re: Fonts and the common guy

Anonymous's picture

Indeed. The whole area of font rendering seems to be one thing that the distro makers always either ignore or screw up. (I must see what the differences are between RH6.x and RH7.x, for example, to see if it's the former or the latter.)

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

In Debian I have to specify which vt to run the new instance of X on - ie

startx -- :1 vt8

or it doesn't work. It's trying to start on vt7 and finding that already in use won't start another X session. Otherwise good article.

david sowerby

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

try this :

startx -- :2

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

Interesting article, but everything I tried on RH7.2 (exactly word for word as the author described) did not make true type fonts go here. I even used gpm to cut and paste stuff out of the article into the bash window. Does not go. True type fonts don't work on RH7.2. They just don't. Good try and thanks for the article, but it just doesn't work. Tried restarting xfs, shutting down/restarting X (both logging out/in and also powering off/on). Doesn't go.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

An easy way is to add Microsoft's true type fonts from the internet using the included script "fetchmsttfonts". Web pages, which these fonts are for, will look much better after you do that. Don't forget to press q when the license agreement is piped through less!

Re: Is Beauty Only Pixel Deep?, Part 2

dscribner's picture

Yes they do. Copy your TT fonts to your TT font directory (like /usr/share/fonts/truetype for example, or perhaps some other directory you've set up for this... just make sure the directory is listed in your xfs config file... /etc/X11/fs/config... if it's not, add it), then as root, change to that directory and run these two commands:

ttmkfdir -o fonts.scale


These will create the two font information files, "fonts.scale" and "fonts.dir", in the directory. Once you've done this, restart your xfs server ("service xfs restart"), log out of root, fire up X and enjoy your fonts.

Re: Is Beauty Only Pixel Deep?, Part 2

unoengborg's picture

I still don't get why I need the font server,

as I can't use it in modern X setups with

antialiased fonts anyway. Or can I?

What I mean is that the /etc/X11/XftConfig

specifies font directories on local disk anyway.

E.g dir "/usr/X11R6/lib/X11/fonts/Type1"

Or is there some way to use fonts from a

font server here?

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

I love the topic!

Unfortunately, my experiments didn't succeed (on Mandrake 8.2). My xlsfonts doesn't take a -server option. A discussion of the -display option to xlsfonts would be useful...

- Chuck

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

That's because Mandrake uses a different port as a check of the XF86Config-4 file would reveal. fslsfonts -server unix/:-1 works for me.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

Time and again have I tried to use 100dpi fonts, rather than 75dpi ones, and have always returned to 75dpi. The 100dpi fonts look ugly as hell - they are way too large, take up too much room, and get generally in the way, in all the boxes I have access to, from 800x600 at 75dpi all the way up to 1600x1200 at 112dpi.

This, together with the purported benefits of anti-aliased fonts, is one of those spurious fads that plague this industry.

Re: You did it a wrong way

Anonymous's picture

You should choose a 100dpi resolution for your display, not 100dpi fonts at 75dpi (which makes them look ugly and bigger). The 100dpi fonts at 100dpi have the same size as the 75dpi fonts at 75dpi.

I also used 110dpi resolution, which looked as good as 100dpi. Have you installed 100 dppi fonts?

I never used the AA fonts, because switching display resolution to 100dpi makes fonts enough good looking (not worse that TTF fonts in MS Windows). And it works in all applications (GTK, X native, Open Office).


PS. MS Windows used 96dpi by default regardless resolution or display size. Why not do the same with X?

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

This is quite a useless article. These things have been covered years ago in the Font deuglification HOW-TO. I don't understadn why I would use two instances of xfs on my computer, anyway.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

This is quite a useless article. These things have been covered years ago in the Font deuglification HOW-TO.
You obviously know a lot about this. So why are you reading for-beginners articles? I'm still learning my system and learnt a few things here.
I don't understand why I would use two instances of xfs on my computer, anyway.
So you can muck about with the second font server without stuffing up your usual one. I think this is the only reason the author did it.

Re: Is Beauty Only Pixel Deep?, Part 2

brianlane's picture

Not to take away from Marcel's nice work, but he never really answered the core question - why run xfs by default? The majority of us are not sharing font servers, and never will. Its a waste of my system resources to fire up xfs when all you need to do is add the paths to your XF86Config-4 file.

And on a related note, if your fonts look ugly when you upgrade to RH 7.3 try setting the DPI for your monitor by adding the DisplaySize command to the XF86Config-4 file in the Monitor section. The width and height are specified in mm and allow the X (server/client?) to figure out the correct DPI setting.

Before doing this my fonts in AbiWord, etc. Looked streched on my 19" monitor. They had been looking fine in RH 7.2

Resist the urge to clutter up your running system with unneeded apps like xfs (and all the garbage that KDE and GNOME start, but more on that from me later).


Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

Another reason I can think of for running xfs is if, heaven forbid, there's a bug that causes xfs to quit then your X server will just hang. It's a simple matter to rectify that by flipping across to a vt and restarting xfs, allowing you to carry on where you left off.

Assuming the X server and xfs use largely the same code to render fonts, if this happened without the X server using xfs, the X server would abort, taking your applications with it.

That's usually a Bad Thing.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

Once I asked the same thing to mharris, the X guy from redhat. He said that using xft keeps X from blocking when rendering fonts. Supposedly if you use non latin fonts, X will briefly lock up while rendering them (watch for mouse stalls). xft keeps this from happening.

That said, I've never had a problem with it (possibly due to the uncomplicated fonts I use), and prefer not to use xft. So while I agree with your preference to not use it, do realize that xft is necessary for redhat's distro to perform well in all settings.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

This is precisely correct. Obnoxious font rendering requests are effectively a (often inadvertent) DoS in X. This includes rendering Asian fonts and rendering large fonts (as in the recent Mozilla style-sheet DoS). Running xfs, it is a simple matter to set limits on the font server that differ from the X server, including RAM, CPU, etc.

Re: Is Beauty Only Pixel Deep?, Part 2

Anonymous's picture

Indeed. A recent example of why separation of font rendering from X rendering is at:
"X-windows remote DoS with big fonts"
Those folks with xfs just restart xfs and move on. Those with internal font rendering generally end up with a runaway X server.