Explanation of fonts
This page tries to explain how fonts work under linux. This is basically a copy of a message I sent to the gentoo user mailing list to explain why fonts look the way they do under different applications
The look of the fonts is determined by freetype. A full desktop has it installed a couple of times. Openoffice and mozilla come with their own, statically linked versions. Then X has it's version, and finally there is the freetype ebuild that installs freetype in /usr/lib. In the current gentoo version this is not so bad anymore as most packages have been changed to use the shared version
Due to a
patent owned by Apple, the freetype library comes standard with the bytecode
interpreter disabled. People who either don't care about patents, or think the
patent is not valid, or live in a country where the patent doesn't apply can
enable this bytecode interpreter with the setting described in the recent
article on www.register.co.uk. Standard the gentoo compiled libraries enable
this feature, as without it fonts are butt ugly. The binary version of
openoffice doesn't have it enabled though. The trick with
LD_PRELOAD="/usr/lib/libfreetype.so" oofice actually forceably
disables the freetype that comes with openoffice and replaces it with the
system library.
Now, there are multiple ways for programs to use fonts:
- Load font files from disk and render them on client-side (not X-Server side). This is what openoffice and default configured mozilla do (mozilla can be configured to use Xft)
- Use X core fonts. This is the traditional way of displaying fonts. This works, but doesn't allow access to the font for programs (usefull for Now there are multiple ways for programs to use fonts: printing, that's why fonts must be installed for openoffice). Also core fonts don't allow anti-aliassing.
Use the new (since XFree-4.0) Xft extension and the Render extension. These two extensions provide for an easier selection scheme (more properties), more data about the fonts, and anti-aliassing. With the Xft-2.0 version, the render extension is not nescesarry anymore to use antialiassing (although it improves performance)
The XFt2 extension makes use of the fontconfig library. This library provides code for the system to find fonts and even configure variations or features like antialiassing and subpixel rendering. This library has it's configuration in /etc/fonts/fonts.conf and /etc/fonts/local.conf. For fontconfig it is no longer necessary to create font description files. Putting a font directory in /usr/share/fonts is enough for the fonts to be found. Fontconfig can also handle big amount of fonts without big performance issues.
Gui toolkits such as gtk and qt often put another abstraction layer above these methods and provide for a unified font object that can be influenced with gtkrc files in the case of gtk. It does not handle rendering though, so 12pt courier new is as ugly in qt as in gtk. The only difference is available in the backends, as the core font method doesn't allways give results equal to the xft method. Gtk and Qt both allow user choice of the backend, but modern versions both use Xft by default.


