Updated: 2024-09-25
Created: 2004-02-15
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.
In practice, a reasonable “vanilla” setup can be done without looking at every little detail. Here are some suggestions:
heavy) that force rendered glyphs to fit into a pixel aligned box, by significantly altering the shape of a character. These hints make glyphs legible and high contrast without antialiasing on low resolution displays (100DPI and below) with the costs that they are very expensive to make and distort character shapes.
light) that help the rasterizer preserve the shape of the character. These hints result in good quality characters and fairly good contrast on higher resolution displays (120 DPI and above) but glyphs boxes are not pixels aligned which usually means that anti-aliasing is needed.
/usr/local/share/font/ps1/
and
/usr/local/share/font/ttf/
.fonts.scale
), fontconfig
(/etc/fonts/local.conf
), GhostScript
(/usr/share/gs/
7.07/Fontmap.GS
,
$GS_FONTPATH
) and OpenOffice.org
($SAL_FONTPATH_PRIVATE
, or use symbolic links
from share/fonts
or use
spadmin
).freetype
module is
loaded before the bitmap
module. The
freetype
module can also handle bitmap fonts, and
the bitmap
module has an important misdesign with
respect to DPI handling.These terms give a somewhat simplified guide to some important notions.
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.
There is another similar list of formats in the Fonts FAQ.
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.
Microsoft Typography has a useful list of fonts bundled with common products from Microsoft and other companies.
The Google Web Fonts is a collection of various unrelated typefaces, including several listed below, rather than a family of typefaces.
-misc-fixed-
UCS extended fonts
which are very useful.The Tex Gyre family is designed to replaced the classic Adobe set:
It is an extensive remake and extension of the freely available 35 base PostScript fonts distributed with Ghostscript ver. 4.00. The important aspect of the project is providing not only the support for TeX but also the cross-platform OpenType format of the fonts.
These are the typeface that might be considered equivalent:
TeX Gyre | URW | Adobe etc. |
---|---|---|
Adventor | URW Gothic L | Avant Garde Gothic |
Bonum | URW Bookman L | Bookman |
Cursor | Nimbus Mono PS, Nimbus Mono L |
Courier |
Heros | Nimbus Sans L | Helvetica |
Schola | C052, Century Schoolbook L |
New Century Schoolbook |
Pagella | P052, URW Palladio L |
Palatino |
Termes | Nimbus Roman No9 L | Times |
Chorus | Z003, URW Chancery L |
Zapf Chancery |
Many distributions have configuration files for FontConfig (from FreeDesktop and Artifex) with suitable aliases.
The URW++ foundry has contributed a full set of Type1 fonts (Artifex, CTAN) similar to the classic Adobe set, and they are bundled with GhostScript or with the sample X11 implementation or with most TeX/LaTeX distributions.
URW | Adobe etc. |
---|---|
URW Gothic L | Avant Garde |
URW Bookman L | Bookman |
Nimbus Mono PS, Nimbus Mono L | Courier |
Nimbus Sans L | Helvetica |
C059,
Century Schoolbook L | New Century Schoolbook |
P052,
URW Palladio L | Palatino |
Standard Symbols PS | Symbol |
Nimbus Roman No9 L | Times |
Z003,
URW Chancery L | Zapf Chancery |
D05000L,
Dingbats | Zapf Dingbats |
Many distributions have configuration files for FontConfig (from Artifex) with suitable aliases.
Unrestricted availability:
The Microsoft web core fonts are a set of rather bland but quite legible and heavily 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. The typeface names are:
CrOSCore | Liberation | Microsoft Web fonts |
---|---|---|
Arimo | Liberation Sans | Arial |
Cousine | Liberation Mono | Courier New |
Gelasio | n.a. | Georgia |
Tinos | Liberation Serif | Times New Roman |
CrOSExtra | Microsoft ClearType |
---|---|
Carlito | Calibri |
Caladea | Cambria |
DMCA Sans Serif | Consolas |
ClearType | Similar |
---|---|
Calibri | Carlito |
Cambria | Caladea |
Candara | n.a. |
Consolas | DMCA Sans Serif |
Constantia | n.a. |
Corbel | n.a. |
t1-teams
.t1-cyrillic
.Somewhat restricted:
As part of other typeface sets there are Courier, Cousine, Courier New, Gyre Cursor, DejaVu Sans Mono, Droid Sans Mono, Noto Sans Mono, Plex Mono, Ubuntu Mono, Free Mono, but there arer also some specialize monospace only typeface sets:
There are first some pseudo font families, generic typeface names which are as a rule mapped to an actual typeface name:
Serif
SansSerif
Monospaced
Dialog
(form captions)DialogInput
(form fields)serif
sans-serif
monospace
cursive
(handwritten)fantasy
(decorative)The generic Fontconfig names are a subset of the CSS2 ones:
serif
sans-serif
monospace
As a special case sans serif
is usually taken
as a synonym of sans-serif
. Xft1 used similar names
which are obsolete:
serif
sans
mono
In $KDEHOME/share/config/kdeglobals
:
font
menuFont
taskbarFont
toolBarFont
activeFont
(active window)In $KDEHOME/share/config/kdesktoprc
:
StandardFont
(desktop icons)Artifex have produced a PDF file with a list of the output of several font rasterizers.
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 X font servers.
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.
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 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.
bitmap
0
(screen resolution).type1
xfs
font server, and generally rasterizes Type
1 fonts less well than the FreeType2 Type1 rasterizer
contained in the freetype
module.freetype
xtt
module is preferred for Asian
fonts.xtt
freetype
module, but with additional logic for
the handling of large Asian fonts with specific character
mappings.The way to select X fonts is with an XLFD.
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.
You can test font rendering with xterm for fixed-width fonts:
xterm -xrm '*.VT100.renderFont: true' -fn \ '-*-lucidatypewriter-medium-r-normal-*-*-100-*-*-m-*-iso10646-1'
You can use xedit for variable-width fonts:
xedit -xrm '*.font: -*-times-medium-r-normal-*-*-100-*-*-p-*-iso10646-1'
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.
These are obsolete, pray that you never need to deal with this font system.
Fontconfig uses FreeType2 to render glyphs from fonts, and its main role is as a font-file finding wrapper to FreeType2. Its main rendering options are a simplified version of the FreeType2 fonts:
Hinting means adjusting the shape of rendered fonts to look better on low density displays. There are three types of hinting:
have heavy hintswith their own hinting programs, as these are very time consuming to write.
This renders glyph with smooth edges instead of jagged black-and-white edges, reduces glyph sharpness by making those edges fuzzy, and there are four types:
The rendering is controlled by some main parameters with non obvious details:
ClearTypestyle renderers) which usually only hints in the vertical direction.
A good way to test the parameters is to use recent versions of xterm with Fontconfig, specially for fixed-width fonts:
xterm -xrm '*.VT100.renderFont: true' -fa 'noto mono:size=11:dpi=120:hinting=1:autohint=0:hintstyle=hintslight:antialias=1:rgba=rgb:lcdfilter=lcdlight'
fonts.conf
detailsSomeone has posted a nice example.
GDK_XFT
1
enables use
of Fontconfig. In GTK versions starting with 2.2 this is
the default.XFT_DEBUG
0
produces various debugging outputm
according to the following table:
XFT_DBG_OPEN | 1 |
XFT_DBG_OPENV | 2 |
XFT_DBG_RENDER | 4 |
XFT_DBG_DRAW | 8 |
XFT_DBG_REF | 16 |
XFT_DBG_GLYPH | 32 |
XFT_DBG_GLYPHV | 64 |
XFT_DBG_CACHE | 128 |
XFT_DBG_CACHEV | 256 |
XFT_DBG_MEMORY | 512 |
I found this info here.
TBD
GhostScript uses a completely different font
system from all other applications, based on
Fontmap
font lists.
TBC
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
xdvi
, dvips
, ...TBD
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 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
comp.text.fonts
FAQ.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:
cm-unicode
.These are good and well hinted but not very much freeware:
These are pointers to some of the entries in my technical blog where font related issues are discussed:
freetype
.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:
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:
fc-list
command. Note that it appears that the
property style
also gets listed, which is quite
important as apparently there are no standard values for it,
and it overrides the weight
and
slant
properties.foundry
: Font foundry name.light
, medium
,
demibold
bold
, black
(optionally prefixed by weight=
).roman
, italic
,
oblique
(optionally prefixed by
slant=
).proportional
,
dual
, mono
,
charcell
(optionally prefixed by
spacing=
).scalable
(true
/false
): whether glyphs can
be scaled.outline
(true
/false
): whether the glyphs
are outlines.pixelsize
(floating point): pixel size.dpi
(floating point): target dots per
inch.scale
(floating point): scale factor for
point->pixel conversions.aspect
(floating point): stretches glyphs
horizontally before hinting.charset
(string): unicode character sets
encoded by the font.lang
: comma separated list of RFC-3066-style
languages this font supports.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:
Courier-10:foundry=Adobe:medium:roman:dpi=100:charset=ISO-8859-1
might be equivalent to the XLFD
-adobe-courier-roman-r-*-*-*-100-100-100-*-*-iso8859-*
.Lucida-12:bold:roman:dpi=100:charset=ISO-8859-1
might be equivalent to the XLFD
-*-lucida-bold-*-*-*-*-120-100-100-*-*-iso8859-*
.