Fontconfig

The fontconfig library is intended to provide uniform font selection and configuration amongst all GUI applications. Even though it is common for various desktop environments to provide their own font overrides and configuration, still fontconfig is the underlying library.

Generic
fontconfig uses XML files in directory to generate its internal configuration. By default it parses (users should not edit this file!) which sets some sane defaults and usually contains code to also parse  content. In addition there is directory that contains various possible configuration files that each cover some aspect of fontconfig. It's customary to symlink necessary files to. These files are executed in order they are named, for this reason their names start with a two digit number with the first (tens) indicating class, that is, what the file affects.

Gentoo specific way
Gentoo ships an eselect module (eselect fontconfig) that does exactly what was described in generic way - it manages symlinks of files in by adding or removing them from the  directory. For obvious reasons changing system wide configuration requires appropriate permissions.

Enabling a file
Files can be enabled either by filename or by the number in brackets. These two do the same thing:

Disabling a file
Files can be disabled likewise:

Custom system wide configuration
Enable and create  (this is an XML file, you have been warned).

Per-user configuration
Enable (possibly enabled by default). And use (same format as )

Checking configuration
You can check the default font replacement, for example for Arial, by typing:

Anti-aliasing, hinting and sub-pixel rendering
Anti-aliasing is enabled by default and makes fonts less blocky. Hinting is an attempt to cope with the low pixel count per unit of area of current displays.Correct hinting makes characters more crisp but since font metrics aren't changed (and arguably should not change) affects how overall the rendered text looks like. Sub-pixel rendering uses the fact that LCD matrix has three primaries to effectively triple the resolution of text but can make characters appear not entirely black. To combat that lcdfilter is to be used with sub-pixel rendering (available for newer fontconfig) but it can blur the characters too much. In the end this entirely depends on person how they like their text.

Forcing hinting
The default fontconfig behaviour regarding hinting is unknown [personal note: what is this madness, how can one of the key components of Linux graphical stack be unknown?!] but it can be made deterministically sub-optimal by making a system wide default.
 * 1) First enable
 * 2) Edit the file to include full hinting by default

Using sub-pixel rendering
It's important to determine the sub-pixel layout of the LCD matrix. It's usually RGB but the only way to be sure is to either consult display specification or use this sub-pixel layout test to determine it. Once determined, enable the appropriate file.

It's strongly advised that lcdfilter, if available, is used with sub-pixel rendering. It comes in different varieties but the default should be appropriate for all common fonts.

Regarding autohinter
Autohinter attempts to do automatic hinting disregarding any existing hinting information. Until recently it was the default because TrueType2 was covered by patents but now that they have expired there's very little reason to use it. From technical point of view it does better than broken or no hinting information but it will be strongly sub-optimal for fonts with good hinting information. Generally system fonts are of the second kind so autohinter should not be used.

Infinality
Infinality is a somewhat controversial set of patches for FreeType and accompanying fontconfig files. The goal of Infinality is to provide higher quality font rendering including emulation of other OS font rendering styles. It's at best of beta quality but newer FreeType ebuilds have a USE flag for enabling Infinality. It should be kept in mind that some fonts can be rendered worse than with vanilla FreeType and furthermore Infinality is known for making applications crash under certain conditions.

Enabling Infinality
Enable the 'infinality' USE flag by editing make.conf either manually or by using euse tool.

And then rebuilding affected programs.

Unless messages shown after rebuild tell otherwise, enable 52-infinality.conf.

Configuring Infinality
Infinality can be configured in various ways including custom configurations but easiest is to use pre-made profiles shipped in media-libs/fontconfig-infinality that along with eselect modules should have been installed as dependencies of infinality USE flag.

Quick and reasonable config
It's also recommended to disable all fontconfig settings except for 52-infinality.conf as they interfere with the rendering of infinality styles:

Certain fontconfig settings do not interfere with how the fonts are rendered, but rather determine the default fonts for font-families (such as Monospace, sans-serif, etc.). Such settings (for example the configurations) can be left enabled.

Explanation
Infinality provides FreeType environment variables that can be used to configure features introduced with its patches as well as fontconfig files to be used with these changes. Fontconfig file sets are administrated on Gentoo via eselect infinality while the FreeType behaviour is set using eselect lcdfilter.

These eselect modules function as usual. Listing available fontconfig file sets.

Listing available FreeType variable sets.

Both sets should match of course except when there are multiple matches possible such as shown below.

Picking fonts
Choosing the right font can be trickier than deciding on the right hinting type.For one reason or another fonts will not be perfect but it's certainly doable to make that same fonts look better than, say, Windows 7 default font configuration. The following information is biased but it can't be helped.

External resources

 * Arch Linux Wiki on this topic - an in-depth article on Linux font configuration and font selection
 * Official fontconfig documentation for users
 * Wikipedia article on font hinting