MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

*DocIndex - X

Fonts On X

* Font Anti-Aliasing
* "My Fonts Are Too Small!"
* Adding Fonts
* Font Viewers
* Font Resources

Related Resources:

KDot: How to configure your Anti-Aliased desktop
gdkxft README
Font HOWTO
XFree86 Font De-uglification HOWTO
man xfs

Revision / Modified: June 11, 2002
Author: Tom Berger

 

* Font Anti-Aliasing

Font anti-aliasing (AA) works by adding shaded pixels to font outlines, thus making the font look smoother. This feature has been introduced in XFree 4.0.3 via the 'RENDER' extension and the X FreeType interface library (Xft).
To actually get AA applications on the desktop, however, the respective widget sets have to support AA as well. Qt (KDE) does so natively, whereas GTK+ 1.2 (GNOME, GIMP) requires the installation of a separate library. GTK+ 2.0 (along with GNOME 2) will add native support for AA.

To get AA on your desktop, you first have to test if XFree offers the needed RENDER extension for your graphics card. Run this command in a terminal:

xdpyinfo | grep -c -i render

If you get a '1', you can go on. If not, you'll have to wait until XFree offers RENDER for your card, too.

Enabling AA on KDE is very easy: Open the 'Control Center': 'LooknFeel' - 'Fonts', mark the field 'Use Anti-Aliasing for fonts', save, logout and in again. Et voila, anti-aliasing.

With GNOME and GTK it's a tiny bit more complicated. Get the RPM from thegdkxft home page and install it. Select the 'gdkxft' theme from GNOME's Control Center. If you are not going to use GNOME, copy the file '/usr/share/themes/Gdkxft/gtk/gtkrc' to your home directory and rename it to '.gtkrc'. Add the lines

LD_PRELOAD=/usr/lib/libgdkxft.so.0
export LD_PRELOAD

to your '~/.bashrc', log out and in again and your GNOME desktop or GTK applications will be anti-aliased. To tweak the font sizes which are a bit odd (especially for menu titles), edit your '~/.gtkrc' and reduce font sizes. You also might want to set the 'menu*' styles to 'lil-sans'.
If you want to use another theme, select it from GNOME's Control Center, and choose 'Custom Font'. There might be quite some tweaking required, especially with the menu fonts which tend to get cut off (that's because GTK+ internally does not know about AA).

General settings can be applied either to '/etc/X11/XftConfig' or to a local '~/.xftconfig' file. One thing you should do in any case is to put a hash (#) in front of all the listed directories in 'XftConfig' which are not present on your system. This will have a positive effect of the time applications need to start. Read the KDot tutorial on How to configure your Anti-Aliased desktop for an overview on the syntax used in 'XftConfig'.
If your monitor is a TFT (laptop, flat panel), you should have a look at Justin Mason's concise mini-HOWTO on Sub-Pixel Font Positioning.

Notice that there is a hacked version of libXft which turns off the sub-optimal hinting.

* section index * top

* "My Fonts Are Too Small!"

You can fix this on two or even three levels: on a system level or on an application level. If your are using a desktop environment like KDE or GNOME, you can change the default font sizes from their respective Control Centers.

On the system level, small fonts can be caused by the X font server (xfs) loading a smaller set of fonts first or by a wrong DPI (dots per inch) setting or both.

The font server configuration file is '/etc/X11/fs/config'. The directories listed under 'catalogue' are searched one after the other for a font requested by X, i.e. the first font that matches, 'wins':

/usr/X11R6/lib/X11/fonts/75dpi:unscaled,
/usr/X11R6/lib/X11/fonts/100dpi:unscaled,

This loads the (smaller) 75 DPI fonts first. If you reverse the order of these entries, the bigger 100 DPI fonts will be used instead. If you can't find an entry for the 100DPI fonts, you have to install them first (package 'XFree86-100dpi-fonts').
Restart the font server as 'root' with service xfs restart to let the changes take effect (restarting X will not do).

Traditionally, X assumes a DPI setting of 75. Most modern monitors however follow the Windows standard and use 96 DPI. To find out your current DPI setting, run:

xdpyinfo | grep dots

XFree 4 offers an option to correct this setting. Open '/etc/X11/XF86Config-4' as 'root' in an editor, scroll down to the 'Monitor section' and add below the 'Model Name' line this:

DisplaySize xx yy

Substitute 'xx' with the width of your screen in millimeters, and 'yy' with the height. Save and restart X.

* section index * top

* Adding Fonts

Usually you want to use 'DrakFont' for this via the Mandrake Control Center ('System' - 'Fonts'). It's not only more convenient, but also does some sanity checks. But if you what to do it the hard way or if DrakFont doesn't seem to work for you, follow these instructions:

PostScript (*.pcf)

  1. As 'root', create a new directory for your fonts in '/usr/X11R6/lib/X11/fonts' and put your new fonts in there.

  2. Run mkfontdir /usr/X11R6/lib/X11/fonts/new_directory
    This creates the files 'fonts.alias' and 'fonts.dir'.

  3. Run xset fp rehash
    Ready.

  4. Restart the X Font Server as 'root' with: service xfs restart

TrueType (*.ttf)

  1. Create a new directory as 'root' for the fonts you want to add (e.g. withmkdir /usr/share/fonts/my_ttf.).

  2. Put your fonts into this new directory. Make sure their file names consist of small letters only. Make sure there are no empty spaces within the filenames. Check the permissions (ls -l) on the new font directory (should bedrwxr-xr-x) and the fonts (should be-rw-r--r--).
    If you get something wrong here, you might not be able to restart X!

  3. Inside the new directory, run ttmkfdir > fonts.scale to create a 'fonts.scale' file to be processed by 'mkfontdir'. 'ttmkfdir' is part of the 'freetype-tools' package.

  4. Sheldon Lee Wen adds: "If you get errors such as 'unknown encodings' those fonts won't get added to the 'fonts.scale' or 'fonts.dir' files and hence will not be accessible. To make those fonts available try running

    ttmkfdir -c -p > fonts.scale

    You'll still get the errors but your fonts should get added to the 'fonts.scale' file." You might not be able to use those fonts in all applications, though.

  5. Run mkfontdir.

  6. Run chkfontpath --add new_font_directory as 'root'.
    This will add the directory to '/etc/X11/fs/config'.

  7. Run xset fp rehash as 'root' to make sure that X recognizes the new fonts.

  8. Restart the X Font Server as 'root' with: service xfs restart

You can use font directories on other file systems, too, as long as

  • there's read and write access to this file system (i.e. you can't use fonts on a Windows XP NTFS partition),
  • the partition is automatically mounted during boot,
  • the path to the font directory is listed in '/etc/X11/fs/config'

I'd rather advise copying the fonts over to a Linux font directory, though.

Caveats:

  • It is very easy to get something wrong here. If you do, either 'xfs' won't be able to come up and so X won't work anymore or (with XFree 4.1) X will silently ignore the error and the fonts just won't be available.
    If X does not come up anymore after font configuration, switch to another virtual console by pressing <ALT F2>, log in as 'root', open '/etc/X11/fs/config' in an editor, put a hash (#) in front of the new directory entry, safe the file and reboot.

  • Make sure the licenses of the fonts you are going to use allow you to use them as you wish. Some font licenses require you to pay a fee if you are using the font for commercial purposes.

* section index * top

* Font Viewers

The 'Mandrake Control Center' includes a font viewer ('System' - 'Fonts'), and if you are using a desktop environment, you can either use the respective fields of their Control Centers or the standard font preview field available from the configuration dialog of most applications.

  • 'xfontsel' (part of the 'XF11R6-contrib' package) displays fonts known to the X server. In case you wonder what the 'select' button is for: it copies the font recognition string to the clipboard.

  • gfontview "is a small GTK+ font viewer for PostScript Type 1 and TrueType fonts. It allows you to display any character or string in a particular font as well as all glyphs present in it".

  • My personal favourite however is 'gtkfontsel'. Sadly it is only available in a source archive from a few servers.

* section index * top

* Font Resources

TrueType's 'Great TrueType Fonts' page lists all major resources for TT fonts.
Please pay attention to copyright issues, many of these fonts may not be redistributable!

Fonts packages available at the RPM repository at Rufus.Org in RPM-Format.

Shareware Typefaces is a large, search-able collection of freeware and shareware fonts. A similar resource is available at Font Freak.
More sites are listed in the Fonts - Collections section of the Google Web Directory.

The fonts page of GIMP.orglists some packages useful for GIMP. If you've ever encountered those annoying script-fu errors because of missing fonts, this is the place to go!

Freshmeat lists font packages and font applications.

* section index * top

 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.