Linux fonts (mostly X11)

Updated: 2013-09-10
Created: 2004-02-15

This document is an incomplete draft.

Fonts in Linux can be used by several different applications, and sometimes in several different ways for each application. Since they have not been designed into some kind of framework, there is little similarity, to the point that often different applications use distinct copies of the very same font file, in different directories.

It is possible to partially retrofit some sensible framework in this mess; it is also important to know some of the various little details, because they practically matter quite a bit.

Practical summary

In practice, a reasonable “vanilla” setup can be done without looking at every little detail. Here are some suggestions:

Important concepts (090816)

These terms give a somewhat simplified guide to some important notions.

Alphabet
An alphabet is a collection of characters; a character is an abstract concept, and cannot be read, written or spoken. The same character can be in different alphabets. Note that a pictogram counts as a character here.
Character set
A character set is a collection of character codes, which are numbers each of which corresponds to a character in the same alphabet. The same character code can correspond to the same character in different character sets.
Encoding
An encoding is a way to represent character codes belonging to a character set as bits and bytes in computer memory. The same encoding can represent the same character code in different encodings, and viceversa the same character code can be represented very differently in different encodings.
Glyph
A glyph is a shape that represents a character. The same character can be represented by many different glyphs.
Rendering
The action of taking a non perceivable representation of some entity and turning it into another perceivable one. For example, rendering a MIDI file to sound, or a glyph outline to a bitmap.
Rasterizer
A program that renders bitmaps from some other representation of an entity, for example a glyph outline, or an entire web page.
Renderable glyphs
A renderable glyph is some representation of a glyph that can be rendered visually. Within digital fonts renderable glyphs are usually pixmaps, or outlines/programs that can be rasterized to pixmaps. In some case a digital font contains all three types of renderable glyphs.
Font
A font is a collection of renderable glyphs.
Typeface
A typeface is a collection of fonts with a similar or compatible visual style.
Digital font
A digital font is a font organized as a table of rasterizable glyphs, so that each glyph has a numerical position within the font. Some digital fonts can contain the same glyphs arranged in a different order. The same digital font file can contain several digital fonts, all sharing the same renderable glyphs, but in different positions.
Font system
A font system is some set of software that allows program to access and render digital fonts.

Sometimes the terms used above are used somewhat interchangeably, either by mistake, or because it often happens that for convenience the same values are given to different entities. For example, a character code can be used also as the position of a rasterizable glyph in a digital font, and as its own representation in an encoding.

Also, things re much more complicated than can be briefly described here; for practical purposes some alphabets contain not just characters but also parts of characters, and so therefore digital fonts for those alphabets.

There are some resonable discussions of some of these issues, for example this introduction to Unicode and these comments on the relationship between Unicode and fonts both of which contains generally useful concepts.

Font formats

BDF
Verbose, text based bitmap font for X11.
SNF
Binary bitmap font compiled from BDF, with endian dependent representation.
PCF
Binary bitmap font compiled from BDF, with a platform and endian independent representation.
PMF
TBD
PS
Type 3 PostScript font, can contain any PostScript command.
PFA
Type 1 PostScript font program in text format.
PFB
Type 1 PostScript font program in binary format.
MM
Multiple master PostScript font program.
TTF
TrueType font program.
TTC
OpenType font program.

There is another similar list of formats in the Fonts FAQ.

Font licensing

What follows is not legal advice, but personal opinions of a legally unqualified programmer.

Typeface licensing is very, very different from country to country, but font file licensing is more uniform.

The most important concept for typefaces is that virtually no mainstream typefaces are original, essentially all are subtle variations of designs that might be several centuries old.

In general what really matters is the situation in the USA; in it typefaces cannot be copyrighted, but they can be trademarked. Therefore there are many clones of the same typeface, with different and sometimes subtly allusive names.

In other countries typefaces, and thus fonts, may be subject to design patents or similar legal restrictions.

As to font files, in the USA bitmap font files in the USA cannot quite be copyrighted, because the underlying typefaces cannot be; but scalable font files can be copyrighted, because they are programs.

As to scalable font programs, there are several classes of licensing, which reflect those for programs in general, but with some important twists. The most important ones are whether the font program is licensed for both print and screen use (screen use is usually not an issue, font program publishers make most of their money from printer fonts) and whether it is licensed for redistribution, and in particular for a embedding into the file that uses it (usually font program publishers make lots of money from selling to printing shops). There are several pitfalls, but fortunately font program licensing is enforced somewhat sporadically.

Open source
Licenses for font programs that are distributed with an open source or free software license, and can be modified and redistributed without restrictions.
Freely redistributable
Licences for font programs that can be redistributed without restriction, standalone or embedded, but not modified.
Embeddable
These licences allow redistribution of font programs but only as embedded in structured printable document formats.
For non commercial use
Licenses that allow use of a font only in non commercial organizations for non commercial purposes.
For personal use
Licenses allowing use of a font only by inviduals, and usually not in the course of a commercial activity.
For use with a printer
These licences, common for Type1 fonts, allow sue of the font with a fixed number of printers, and usually with any number of related computers.

Important font families

Microsoft Typography has a useful list of fonts bundled with common products from Microsoft and other companies.

There are first some pseudo font families, generic typeface names which are as a rule mapped to an actual typeface name:

CSS2
serif, sans-serif, monospace, cursive (handwritten), fantasy (decorative).
Java
Serif, SansSerif, Monospaced, Dialog (form captions), DialogInput (form fields).
Fontconfig
The generic Fontconfig names are a subset of the CSS2 ones: serif, sans-serif, monospace. Xft1 used serif, sans and mono, but these are obsolete like Xft1. As a special case sans serif is usually taken as a synonym of sans-serif.
KDE
In $KDEHOME/share/config/kdeglobals: font, menuFont, taskbarFont, toolBarFont and activeFont (active window); in $KDEHOME/share/config/kdesktoprc: StandardFont (desktop icons).

Then there are fonts which implement specific typefaces or typeface families:

base X11 bitmaps fonts
These include bitmap versions of the Adobe 14, some terminal fonts, and some utility fonts, usually in a number of common sizes at 100dpi and 75 dpi. Since they have been hand tuned, they usually look best on screens, and render most quickly and reliably. Recent versions incorporate the -misc-fixed- UCS extended fonts which are very useful.
Helvetica
There are quite a few variants of Helvetica, often but not always with different names, and as a rule they are quite suitable for screen use, in part because of the lack of serifs, in part because it is a typeface that lends itself well to small bitmaps. The X bitmap version is particularly legible. The Arial font is a clone of Helvetica, and allegedly it has the same metrics as the Adobe Helvetica typeface.
Courier
There are endless variants of Courier, for example Bitstream Type 1 and Speedo freeware, URW Type1 freeware, Adobe bitmap freeware, and IBM Type1 freeware. But lots lots more. Usually it is the best monospaced font for a few reasons:
  • It is usually available in both roman and bold with exactly the same metrics, in particular the X bitmap version.
  • The bitmap and some other versions usually are hand tweaked for low resolutions.
  • Some of its variants are fairly compact, in particular in the vertical dimension, which means they are nice for editing source code.
Adobe 14
Courier (medium, bold, italic, bold italic), Helvetica® (medium, bold, italic, bold italic), Times® (medium, bold, italic, bold italic), Symbol and ITC Zapf Dingbats®.
Adobe 35
ITC Avant Garde Gothic® (book, oblique, demi, demi oblique), ITC Bookman® (light, italic, demi, demi italic), Courier (medium, oblique, bold, bold oblique), Helvetica® (medium, oblique, bold, bold oblique), Helvetica Narrow (medium, oblique, bold, bold oblique), New Century Schoolbook (roman, italic, bold, bold italic), Palatino® (medium, italic, bold italic), Symbol, Times® (roman, italic, bold, bold italic), ITC Zapf Chancery® (italic) and ITC Zapf Dingbats™.
Java
Lucida Bright, Lucida Sans, Lucida TypeWriter.
HP PCL 45
Albertus® (medium, extra bold), Antique Olive™ (medium, italic, bold),Clarendon™ Condensed, Coronet™, Courier (medium, italic, bold, bold italic), Garamond™ Antiqua, Garamond Halbfett Kursive, Letter Gothic™ (medium, italic, bold), Marigold™, CG Omega™ (medium, italic, bold, bold italic), CG Times™ (medium, italic, bold, bold italic), Univers® medium (medium, italic), Univers Bold (bold, bold italic), Univers Condensed (medium, italic, bold, bold italic), Arial® (medium, italic, bold, bold italic), Times New Roman® (medium, italic, bold, bold italic), Symbol and Wingdings®.
Adobe Utopia, Bitstream Charter
These two typefaces have been contributed as gratisware to the X project in Type 1 format. They are nice legible fonts that unfortunately almost nobody uses.
Microsoft Web
The Microsoft web core fonts are a set of rather bland but quite legible and very well hinted Truetype fonts. They come with a peculiar but liberal license: they are free of charge and can be freely distributed, but only by offering them for download, and with no modifications to their packaging.
Liberation
Liberation fonts are similar to and metric compatible with the 3 most common Microsoft fonts. They are not well hinted.
CrossCore
CrossCore typefaces are derived from the Liberation typefaces (thus metric compatible with the 3 most common Microsoft fonts) and the related fonts are part of the Google web fonts collection, being called Arimo, Cousine and Tinos.
They have a more liberal license than the Liberation fonts and therefore have been extended. They are not well hinted.
Droid
Droid are fonts created for mobile phones running the Android platform, but they are platform independent and freeware. They have been incorporated into the Google Web Fonts which supercede them.
Google Web Fonts
Google have released a large set of freeware fonts for use in the Chrome OS which includes an extended version of the Liberation typeface fonts under different names. Like the Liberation typeface fonts they have metrics identical to those of the popular Microsoft Web fonts; Arimo" is equivalent to Arial, Cousine is compatible with Courier New and Tinos is equivalent to Times New Roman.
There are also many other fonts, including an updated version of the Droid fonts and many decorative fonts.
Bitstream Vera
Vera is a Bitstream typeface that has been released, fairly uniquely, under an open source license. It is fairly good quality even if hinting is not extensive. It has been updated and extended in a few variants, and it has been effectively superceded by DejaVu.
DejaVu
DejaVu is a derivative of Vera, with many extensions and some more hinting.
Bitstream Cyberbit
Cyberbit is an old but very extensive TrueType font which supports a very large subset of Unicode. It can be freely downloaded.
Computer Modern
Computer Modern is a group of typefaces specified in MetaFont for TeX. They have been converted in different ways to other formats like Type 1 and TrueType a few times. The main difficulties have been that by default TeX uses a particularly obsolete character set, and hinting.
Fortunately here are now some quality conversions to more common character sets and formats; the format converted to is usually Type 1, for which fortunately recently the FreeType rasterizer has been notably improved. Some of the packages are:
Antykwa Torunska
Very elegant font from Poland, with a good character set and nice set of variants.
Non Latin with Latin subset
  • Greek Magenta set.
  • Russian t1-teams.
  • Russian t1-cyrillic.
  • Uyghur UKIJ Tuz have both Latin and Cyrillic characters in addition to Arabic ones for Uyghur, in a wide variety of typefaces.
GNU Unifont
Dustismo Sans
GNU free
StarOffice
StarOffice and OpenOffice used to be bundled with a set of Type1 and later TrueType fonts which are similar to the classic Adobe set, called Arioso (Zapf Calligraphic), Chevara, ChevaraOutline, Conga, Helmet (Helvetica) Helmet Condensed (Helvetica Condensed), StarBats (Zapf Dingbats), StarMath (Symbol), Timmons (Times).
URW Type1
The URW++ foundry has contributed a full set of Type1 fonts similar to the classic Adobe set, and they are bundled with GhostScript and with the sample X implementation. They are Bookman L (Bookman), Century Schoolbook L (New Century Schoolbook), Chancery L (Zapf Chancery), Gothic L (Avant Garde), Nimbus Mono L (Courier), Nimbus Roman No9 L (Times), Nimbus Sans L (Helvetica), Palladio L (Palatino), Standard Symbols L (Symbol).
B&H Lucida and Luxi
Lucida and Luxi are similar typefaces, designed by B&H, and they are available free of charge by being bundled with Sun's Java implementation. Lucida is also included in PCF format with the X sample implementation. The scalable versions are not very well hinted (if at all).
Agfa Monotype Thorndale, Albany and Cumberland
These fonts are proprietary versions of Time (Thorndale), Helvetica (Albany) and Courier (Cumberland), specially optimized for display on mobile phones, PDAs and other low DPI screens; they are included with SUSE 9.3 Pro.

Font renderers and tools

Artifex have produced a PDF file with a list of the output of several font rasterizers.

FreeType2

The FreeType project started with the goal of developing a TrueType rasterizer, but is now extended to be a fully general font library supporting all the most important source font formats, in particular PCF, BDF, TrueType, Type1 and OpenType. In general the results are of fairly good quality.

FreeType2 is used inside several renderers, including the X module freetype, and some font X font servers.

X11 bitmap

X11 bitmap fonts exist in a source format, BDF, and can be compiled into a much more efficient binary format, PCF, which is host dependent.

Almost only the fonts bundled with the sample X implementation are available in X11 bitmap format. These are of very high quality, as they have been hand tuned at all available pixel sizes, and include the classic Adobe font set plus several other popular fonts.

These fonts can be rendered (very simply, as they are already bitmaps) by the bitmap module of the X11 server, they can be served by the X11 font server, and they can also be rendered by the FreeType2 library which means they are available under Fontconfig and most other font systems too.

X11 Type 1

The X11 Type 1 renderer in the module type1 and included in the xfs font server almost always produces results that are not as good as those of FreeType2, which also can render Type1 fonts.

t1lib

The t1lib library turns Type1 fonts into bitmaps.

Ghostscript Type 1 and Type 3

GhostScript is a fairly complete PostScript interpreter, so it needs a font engine. It used to have its own for Type1 and Type3 fonts, but it now mostly uses FreeType2 so it can also handle TrueType fonts.

X11 server modules

X11 module bitmap
This module only handles PCF fonts, and has two important limitations in most X implementations until at least XFree86 4.4 and Xorg 6.8.2:
  • It cannot be disabled.
  • It forces the font DPI to either 100 or 75 if specified as 0 (screen resolution).
X11 module type1
This module contains the old Type 1 rasterizer, like the xfs font server, and generally rasterizes Type 1 fonts less well than the FreeType2 Type1 rasterizer contained in the freetype module.
X11 module freetype
This module renders using the FreeType2 library and can handle X11 bitmap fonts, TrueType fonts and Type 1 fonts. In practice it is the only module that should be specified, unless the xtt module is preferred for Asian fonts.
X11 module xtt
This module contains the FreeType2 font library like the freetype module, but with additional logic for the handling of large Asian fonts with specific character mappings.

X11 font servers

X11 standard font server xfs
X11 font server xfstt
X11 font server xfs-tt
X11 font server xfsft
Obsolete in XFree86 release 4.x and later ones.

X11 fonts

The way to select X fonts is with an XLFD.

Resolution independent XLFD font specification

It is very useful to be able to specify X11 fonts in a form that is independent of the actual monitor DPI.

Unfortunately many (including myself until recently) think erroneously that this is done by using * as the specification for the DPI fields in the XLFD.

This is incorrect, because a * in the XLFD only filters/matches XLFDs, does not in itself mean whatever is the screen resolution.

In practice, this means that the actual resolution selected by * depends on the order of directories in the font path: because the selected font will be the first of all those that match, and these are usually returned in the order in which the corresponding font directories are listed in the font path and in the font catalog files (fonts.dir, fonts.aliases).

The correct way to specify the current screen resolution is to use 0 as the DPI in the XLFD. But this does not work with :unscaled bitmaps fonts, because these only strictly match the available, explicitly declared, DPIs. However, it works even with bitmap fonts if one does not specify :unscaled, and since an unscaled font is preferred if it is close, this will usually work.

It usually is a good idea to play it safe, and list each bitmap font directory twice, first with :unscaled and then without, and then list the scalable fonts.

With this order the unscaled bitmap font paths, which have the best on screen quality, will be preferred, but the 0 DPI specifier will then match the right DPI in the scalable bitmaps font paths, and then the outline fonts will be matched if no suitable bitmap font is available, for example:

    FontPath 	"/usr/X11R6/lib/X11/fonts/encodings"

    FontPath 	"/usr/X11R6/lib/X11/fonts/misc:unscaled"
    FontPath 	"/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
    FontPath 	"/usr/X11R6/lib/X11/fonts/75dpi:unscaled"

    FontPath 	"/usr/X11R6/lib/X11/fonts/misc"
    FontPath 	"/usr/X11R6/lib/X11/fonts/100dpi"
    FontPath 	"/usr/X11R6/lib/X11/fonts/75dpi"

    FontPath 	"/usr/X11R6/lib/X11/fonts/Type1"
    FontPath 	"/usr/X11R6/lib/X11/fonts/TrueType"

Unfortunately there is an entertaining bit of code in the dix/dixfonts.c, procedure GetClientResolutions:

/*
 * XXX - we'll want this as long as bitmap instances are prevalent
 * so that we can match them from scalable fonts
 */
if (res.x_resolution < 88)
    res.x_resolution = 75;
else
    res.x_resolution = 100;

It effect is to force the font DPI to either 75 or 100 depending on the screen resolution, if it has been specified as 0. Too bad for those who have screens with a different DPI.

STSF

Because of various limitations of the traditional X11 font system (orientation, full metrics, ...) a new server based font system has been designed and implemented called STSF which is considerably more general and flexible, and can be integrated with the X protocol using the XST extension.

It is has numerous compelling advantages over Fontconfig/Xft2 but since the proponents of the latter are rather more vocal and active and politically astute, the latter has been widely adopted.

Client side font systems

Xft 1.x fonts

These are obsolete, pray that you never need to deal with this font system.

Xft 2/Fontconfig fonts

The single most important detail about Xft2/Fontconfig is that by default the FreeType library it uses is compiled without hinting bytecode support.

Unfortunately the built-in autohinter is not very good, even if it has improved to the point of usability. If you can do so legally, it is a good idea to enable the bytecode hinter.

fonts.conf details

Someone has posted a nice example.

Environment variables

GDK_XFT
With GTK 2.0, setting this to 1 enables use of Fontconfig. In GTK versions starting with 2.2 this is the default.
XFT_DEBUG
Setting this option to a numerical value greater than 0 produces various debugging outputm according to the following table:
XFT_DBG_OPEN1
XFT_DBG_OPENV2
XFT_DBG_RENDER4
XFT_DBG_DRAW8
XFT_DBG_REF16
XFT_DBG_GLYPH32
XFT_DBG_GLYPHV64
XFT_DBG_CACHE128
XFT_DBG_CACHEV256
XFT_DBG_MEMORY512

I found this info here.

Other font systems

Console

TBD

GhostScript

GhostScript uses a completely different font system from all other applications, based on Fontmap font lists.

TBC

Sun Java (091114)

The Sun Java implementation for GNU/Linux, uses FreeType as of 1.60, and comes with its own set of fonts.

It does not use FontConfig, so it has its own Java properties to control font rendering of which the most obvious ones are those for setting anti-aliasing, which are swing.aatext for version 1.5 and for 1.6 awt.useSystemAAFontSettings, which is analogous to the various options FontConfig uses to specify whether and how to antialias glyphs.

Thwere is a fairly good font display and test utility called Font2DTest which is usually at $JAVA_HOME/demo/jfc/Font2DTest/.

There is a FAQ for 1.6.0 font handling.

TBD

TeX: xdvi, dvips, ...

TBD

OpenOffice.org

OpenOffice.org is an integrated suite of office tools, including a word processor. When running under Linux it uses its own font system, currently based around the FreeType2 font rasterizer.

As written in the Dropline FAQ OpenOffice.org uses by default Fontconfig/XFt2, but uses an old version of the FreeType2 libraries.

You can force it to use a new version by using LD_PRELOAD.

This package can also be configured to use a set of per-user extra fonts in the user/font/ directory in its per-user installation directory.

TBC

DeFoMa

DeFoMa is not a mere font system, but a meta-font system, in that it can be used to configure a number of font systems it manages.

TBC

Resources

Font downloads (130910)

Some of the better or freer well-hinted fonts are:

The URW Type 1 fonts also are quite good, and rely on the quality of the Type 1 rasterizer, which is pretty decent in FreeType and getting better. They are part of the standard X11 packages. Other Type 1 fonts:

These are also good but not that well hinted or not at all:

These are good and well hinted but not very much freeware:

Appendix: Some of my notes on fonts (120226)

These are pointers to some of the entries in my technical blog where font related issues are discussed:

Appendix: Miscellaneous documentation

Fontconfig font specifiers

The way to select X fonts is wtih an XLFD, but identifying fonts under Fontconfig is not quite as clear (my impression is that overall Fontconfig is pretentious, unfinished and ill conceived, but we have to deal with it regardless).

From its user configuration manual it appears that Fontconfig font specifiers contain, in this order:

  1. An optional list of comma-separated typeface families.
  2. Optionally, a dash followed by a comma separated list of point sizes (which can be fractional).
  3. Optionally, a sequence of properties, each of which consists of a colon, and either a property name, an equal sign, and a value, or a name that implies both a property name and a specific value.

Unfortunately the manual does not quite list which names and values may be used in properties.

By looking at other parts of the manual it seems that these might be the same as those that can be specified in an XML configuration line, and therefore:

Finally note that quite bizarrely the GNOME font specifiers look similar to, but are not compatible with the Fontconfig ones, even if GNOME uses only Fontconfig.

Some possible examples: