| news - about me - my system - columns - blackbox styles - projects - licenses - the curse - contact | |||
|
Good-looking fonts in X Windows |
|
||
|
path xlife columns 20020521 |
|||
Good-looking fonts in X WindowsXlife column for May 21, 2002:Summary:
1 The ultimate proof: see how it's gonna lookYou may wonder what I'm talking about, or if it's worth all the trouble. You've growned accustomed to the (ugly) fonts of X through all the time you've been using it and they don't bother you so much lately. Besides, you've heard all kinds of reports of nice fonts and even seen screenshots, but there's never been something solid to hold on to. I know, I've been there. So take a look at some images first. Here are a Mozilla, an Opera and a Sylpheed screenshot, without any font enhancement whatsoever. Do they seem familiar? You probably see the same images on your box everyday. Quick note: I've chose Sylpheed, Opera and Mozilla not only because they are quite popular, but because they cover most of the applications types you can expect to encounter and attempt to beautify: pure GTK+, pure QT, and a mixture of GTK+ and internal rendering. Enough stalling: now take a look at the above applications in pretty much the same circumstances as before, only this time running with full font beautification in effect: Mozilla, Opera and Sylpheed. Impressed yet? If the answer is yes, then please read on. 2 DisclaimerIt's NOT as easy as "pop-up the Preferences, choose "Fonts / Aspect / Look nice", mark the checkbox and press "OK". It's not rocket science either. What I'm traying to say is, you'll have to sweat for half an hour, but I'll guide you through gently and explain everything as well as I can. Second, don't expect this paper to be the ultimate resource in font beautification. That would be the Font De-Uglification HOWTO instead. You may ask "so why am I reading this instead of that?" Because you'll discover that the HOWTO may be a little hard to follow, since it resembles a technical specification rather than a newbie's guide. It still holds a lot of useful reference and links and I'm gonna ask you to go read it anyway when you're done here. I don't cover everything here, it's more like a walkthrough. Third, you may notice that some of the fonts in the first set of the images above (such as the menus) may be better off unchanged. That's how I like them, but you'll have full ultimate control over your own setup on a font- and font-size- basis. 3 IntroductionWhat makes the difference betweek "ugly" and "beautiful" fonts? Several things. One of them is anti-aliasing (or AA in short). It's the technique which adds gray pixels in various shades around the edges of black text and thus blurs the jagged and pixelated edges. It works with other colors, too. Another thing is having good quality fonts to start with. Font which are ugly by nature or don't scale well to various sizes are not much nicer when anti-aliased. See what kinds of fonts are out there by browsing through the Font HOWTO (not the same as the FDU HOWTO above). Finally, there's the issue of readability which applies to you directly. How well does the end-product look anyhow? Do you really need anti-aliasing for an 8 pixel text? And other similar questions, which you'll learn how to answer according to your own preferences. 4 Check your XFree86 setupMost of the font beautification became possible only with XFree86 4.0. Version 4.0 came with True Type font support included out of the box, since it included the Freetype2 rendering library. Version 4.0.2 added support for font-antialiasing. So first of all check what X version you have by running X -version in your shell. You should see XFree86 Version 4.0.2 or later. Second, your graphics card driver must support anti-aliasing. To check for this run xdpyinfo and look for "Number of Extensions". If it lists "RENDER" somewhere then you're OK. If not, it means that your XFree86 doesn't include a driver with AA support for your card. Either wait for an updated driver in a future release of X or go hunt for another driver (maybe your card manufacturer makes some for Linux?) 5 Use True Type fontsWhy need True Type fonts in the first place? They usually have much better quality than the other types available on Linux, at any size, and they scale very well. They're so good that just using them instead of the default fonts on your box will make things look better, even without other beautification techniques applied. 5.1 Font serversXFree 4.0+ has True Type support included. If you have a version older than 4.0.2, you can still use True Type fonts through a font server. In addition to making True Type fonts available, font servers can serve all their fonts over a network, therefore allowing you to keep a font repository on just one machine on your internal network and spare the space on the others. Here are some good font servers:
5.2 Getting rid of xfsOn the other hand, if you have XFree86 version 4.0 and later you can dismiss any font server completely as long you don't need to serve fonts remotely. This is the case with Red Hat Linux installations which offer xfs by default. It just uses resources for doing something X can do on its own. So you need to do this:
5.3 Where to get True Type fontsHere are a few places that offer True Type fonts for free: 5.4 How to install True Type fontsChoose or make a directory (tipically under /usr/X11R6/lib/X11/fonts or /usr/local/share/fonts/) where you want to keep the new fonts (something like "myfonts"). Copy the new fonts to that directory (should be a bunch of *.ttf files). Don't forget to add the new font path to a FontPath directive in your X configuration file. That's it. In case you use xfs you have to cd into the new directory and do this:
cd /path/to/myfonts For other font servers please check out the FDU HOWTO. In any case, make sure you apply proper rights on the directory (755) and on the files in it (644). It's a common mistake which will prevent the font server from finding the fonts or even from functioning properly. 6 Use anti-aliased fontsXFree86 is capable of font anti-aliasing through a component called Xft. But don't expect applications to suddenly start displaying AA fonts just because you have XFree86 4.0.2+. X only provides it, they still have to make use of it! However, you don't have to make adjustments on an application by application basis. You have to tackle their GUI libraries instead. A GUI library is code which implements elements that a graphical interface will need, such as scrollbars, buttons, checkboxes and so on. Applications choose a GUI and reference code from it instead of implementing their own interface. Some of the most widespread GUI libs are Trolltech's QT and GTK+ (The Gimp Toolkit). They are the GUI of choice for KDE and Gnome, respectively. There are many others, but very few make use of Xft at this moment. 6.1 Bitmap fonts can not use this!Some fonts, such as the ones called bitmap fonts, can't use anti-aliasing. They will look the same no matter what you do to them. They won't even change size. The Artwiz fonts are an example of such fonts. This is due to the fact that some fonts are defined by mathematical curves, which will adapt to various resolutions and sizes (such as True Type and Type 1), while bitmap fonts simply map characters to fixed images. 6.2 Anti-aliasing in QTYou need at least QT 2.3.0 for AA fonts. Binary QT packages will most likely have Xft usage activated. If you compile QT yourself make sure you enable Xft. Making use of the Xft-enabled QT is very easy. All you need to do is set the environment variable QT_XFT to 1. You can do it on the command line, in /etc/profile, in your ~/.profile or ~/.xinitrc by including the following line: export QT_XFT=1 That's it. If your QT has Xft support enabled you should start seeing AA fonts in all QT-based applications. This includes Opera and Konqueror. 6.3 Anti-aliasing in GTK+At the moment of writing, GTK+ 1.x doesn't support Xft yet. There is, however, a third party hack designed to enable AA fonts in GTK+ applications. It is called Gdkxft. See its home page for installaton details. Basically, you need to install a modified GTK lib, then tell GTK+ apps to use it by setting the environment variable LD_PRELOAD to the full path of the modified lib. It's pretty much the same as with QT from there on, with the major difference that you can decide which fonts (and font masks) to receive AA through the ~/.gdkxftrc file. 6.4 Anti-aliasing in MozillaMozilla is a special case. If you already tried out Gdkxft you may have noticed it only affects menus and dialogs, leaving out exactly what interests you most: the webpage rendering. This happens because Mozilla uses it's own engine for the rendering of the pages and GTK for the rest. You can find a way around this on the Gdkxft page: it's a patch which must be applied to the Mozilla source and will produce a fully AA Mozilla. Compiling Mozilla can take an awful lot of time, however, so you may be better off just replacing a library module taken from an already compiled Mozilla. You'll find both on the Gdkxft page. However, they were provided just for versions 0.9.4 through 0.9.8 of Mozilla last time I checked. I made one for Mozilla 1.0 myself by comparing the patched source file (yes, it's only one) before and after the patch. Since a lot of people have asked for it, here it is. You'll find a patch for the source in case you want to recompile Mozilla for this (recommended) and a binary module, compiled on a i686 with glibc 2.2, which you can try at your own risk. Please remember, they're both made for Mozilla 1.0. I tried the patch against Mozilla 1.0 final and it worked. I haven't tried it on anything more than 1.0. If you're using Galeon, this will affect it as well. No need to to anything special. 6.5 Anti-aliasing in other applicationsThere are quite a few other apps which I'd like to see using AA fonts, since I use them a lot. Some examples are OpenOffice and Lyx. They either render fonts internally, or rely on widget libraries which don't make use of Xft (like Xforms). We can only hope that sooner or later the widget and GUI developers will start using Xft. Some other interesting applications that can make use of Xft are xterm (the one in X 4.0.2+) and BlackBox (see this for a patch). If you know others please let me know. 7 Use even better anti-aliased fonts!David Chester has hacked the libXft.so.1.1 library that comes with XFree86 into using better anti-aliasing algorithms. Vizit his page to see the difference. It's remarkable! All you need to do is replace the original library (most likely placed in /usr/X11R6/lib) with his library, run ldconfig and restart X and the font server. Don't forget to back up the original just in case! 8 Choose from your available fontsThe order the font paths are loaded by X or the font server is actually important. If you have two fonts named "Courier", one of which is a Type 1 font and the other True Type, and the one containing the Type 1 font comes first, that's what X will use. So make sure you move True Type font paths (or whatever paths you'd like to have priority) to the top of the list. You can also define fonts.alias files in the font directories, to specify which font masks should actually return other fonts than they should. Why suffer if you have an ugly font that an application insists on using, when you can map it to something else and be done with it? Here's an example of a fonts.alias entry: lucidasans-bold-8 -b&h-lucida-bold-r-normal-sans-8-80-75-75-p-50-iso8859-1 9 Choose your screen resolutionYou can force X into several resolutions. Generally, when you first set up the X server it inspects your monitor and decides whether you should use 100dpi (for large screens) or 75dpi (for smaller ones). You can override it like this: startx -- -dpi 100 You may want to either use bigger fonts on a small screen, or the other way around. Well, it's your choice. 10 Tweak your configuration to perfectionNow you have all that is needed for a truly enjoyable font experience. What remains is for you to start adjusting your configuration files to your liking. I won't give examples since I would still end up missing your own preferences. Here's what you can do with them:
11 Read this!Please read the two following materials. I never meant this column to cover everything. Between this and those HOWTO's you'll really get to know most there is to know about fonts on Linux and never look back to the old days. Other interesting readings: < Back to the top | Read other columns | Choose what column I should write next! > |
|||
|
Xlife ©2001-2010 Zuavra. All rights reserved. You are welcome to link to this site's text pages, but you must get explicit permission before you may reproduce or quote their contents. You may not link directly to binary files, such as images or tarballs. I do keep logs, you know, and offending sites will get their links redirected to shameful error messages. |
|||