Pretty Fonts Are Possible

Make your fonts go pop!

Let’s be honest: font rendering on "i">Linux tends to suck. Take a look
at a Web page using Firefox on "i">Mac OS X, and then look at the same page using the same
browser on a Linux machine. Mac OS X make fonts look sharp, clear,
and easy to read. Heck, even Windows coaxes
fonts to look decent by leveraging Microsoft’s "i">ClearType technology, while the same fonts on Linux look
thin and pathetic. You’ve probably been looking at those
emaciated Linux fonts so long that you don’t even realize how
bad they really are.

There is, however, a better way. Yes, it is possible for you to
make your Linux fonts beautiful, so readable that words literally
pop out of your monitor! Utilizing a
technology known as sub-pixel font
rendering
, Linux fonts will look as good as, or even better,
than those on Mac OS X.

In this article, you’re going to learn how to implement
the technology, not how it works. If you really want the gory
details about the technology behind sub-pixel font rendering, check
out Wikipedia’s article at "http://en.wikipedia.org/wiki/Subpixel_rendering" class=
"story_link">http://en.wikipedia.org/wiki/Subpixel_rendering
.

There’s one caveat, however: this technique only works on
LCD displays. If you’re still using a
cathode-ray tube monitor… well, LCDs are getting cheaper
every day.

There are two steps you need to perform. The first is the same
for both KDE and "i">GNOME, while the second depends on which desktop
environment you use.

Step one involves a hidden file located in your home directory:
.fonts.conf. In fact, you may have this file
already. To check, run ls.fonts.conf. If
.fonts.conf already exists, open the file in
your text editor. Look over the file, and it should be pretty clear
how the file is structured, with several <match
target=”font”>…</match>
pairs inside a
containing "c"><fontconfig>…</fontconfig> pair.

If the file doesn’t exist, create a new "i">.fonts.conf file with your favorite text editor, and put
the following in it:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
  <edit mode="assign" name="autohint">
   <bool>true</bool>
  </edit>
 </match>
</fontconfig>

Type this next snippet after the last "c"></match> and before "c"></fontconfig> (actually, you can put it next to
any <match>…</match> pair, but
placing it at the end is easiest):

<match target="font">
 <edit mode="assign" name="autohint">
  <bool>true</bool>
 </edit>
</match>

Now save .fonts.conf. Next, you need to
tell KDE or GNOME to use what you just enabled.

If you use KDE, open the KDE Control
Center.
If you know how to do so using the K
menu,
go right ahead; otherwise, just type "c">kcontrol in a terminal. Expand” Appearance& amp;
Themes,” and then select” Fonts.” Make sure that” Use anti-aliasing
for fonts” is checked, and then press "i">Configure to open the” Configure Anti-Alias Settings”
window. Check” Use sub-pixel hinting,” and then select” RGB” from
the dropdown menu. For hinting style,” Medium” should be fine.
Press OK, close the KDE Control Center, and
skip ahead two paragraphs.

If you use GNOME, you need to open the” Font Preferences”
window. If you know how to do that using the menus, go ahead;
otherwise, type gnome-font-properties on the
command line. Under” Font Rendering,” select” Subpixel smoothing
(LCDs)” and press Details to open the” Font
Rendering Details” window. For” Smoothing,” choose” Subpixel
(LCDs),” and for” Hinting,” select” Full.” Make sure that” Subpixel
order” is set to” RGB.” You can now close the window, and then
close Font Preferences.

You’ve changed your settings, but they won’t take
effect system-wide until you restart X. You
can either log out of your session, press Ctrl-Alt-Backspace to
restart X and then log back in, or just restart your machine. After
resuming, you should immediately notice that your fonts are
crisper, easier to read, and far less” jaggy” then you may be used
to seeing. Look at the screenshot to see the difference. The
topmost window uses sub-pixel font rendering.

"http://www.linux-mag.com/images/2006-10/diy/font_hinting_before_after.jpg"
class="story_image"> "http://www.linux-mag.com/images/2006-10/diy/font_hinting_before_after.jpg"
class="story_image">

If things don’t look as good as you’d hoped, make
sure you have nice fonts selected in either the KDE Control Center
or in Font Preferences. The Microsoft set of fonts is good and
readily available for most distributions. In particular, try
Andale Mono for monospaced fonts, and
Verdana for everything else. If
Microsoft’s fonts don’t appeal to you, try the
Bitstream Vera family — "i">Sans and Sans Mono are pleasant
— or try the new’ n improved "i">DejaVu fonts, especially DejaVu
Sans
and DejaVu Sans Mono.

If things somehow blow up and look awful, remove the lines you
added to the .fonts.conf file, or remove the
file completely if you created it from scratch. Change your
settings in the KDE Control Center or in Font Preferences and
reboot. Your old-fashioned looking fonts should reappear.

This technique is known to work on Ubuntu,
Kubuntu, Fedora Core,
and SUSE, and
it should also improve fonts on other distros. If your distro does
or doesn’t work, let Linux Magazine
know, and we’ll try to publish the results some time in the
future.

Try sub-pixel font rendering. Once you see the results,
you’ll wonder how you ever managed without it.

Scott Granneman teaches at Washington University in
St. Louis, consults for WebSanity, and writes for SecurityFocus and
Linux Magazine. His latest book,
Linux Phrasebook is in stores now. You can
reach him at "mailto:scott@granneman.com?subject=Do%20It%20Yourself:%20Pretty%20Fonts%20Are%20Possible"
class="emailaddress">scott@granneman.com
.

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62