[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->] |
A font is a collection of characters for displaying text, normally in a common typeface and with a common size, boldness, and slant.
This chapter discusses the most popular kinds of fonts used on Linux systems: display fonts for use in the X Window System, fonts for use in virtual consoles, and the "fonts" often seen in Usenet and email composed entirely of ASCII characters.
Omitted are reference of the use of fonts with TeX, which are the kind of fonts you're most likely to use when producing typeset output -- it is beyond the scope of this book to cover that issue with the space it needs. However, to print a text file with a font, see Outputting Text in a Font.
For more information on fonts and the tools to use them, see the Font HOWTO (see Reading System Documentation and Help Files).
You can specify a font as an option to most X clients, so that any text in the client is written in the given font. The recipe that describes how to do this is in Specifying Window Font.
When you specify a font as an option, you have to give the X font name, which is the exact name used to specify a specific font in X. (An easy way to get the X font name is described in the first recipe in this section.) X font names consist of 14 fields, delimited by (and beginning with) a hyphen. All fields must be specified, and empty fields are permitted:
-fndry-fmly-wght-slant-swdth-adstyl-pxlsz -ptsz-resx-resy-spc-avgwdth-rgstry-encdng
The preceding line was split because of its length, but X font names are always given on one line.
The following table describes the meaning of each field.
FIELD | DESCRIPTION |
fndry |
The type foundry that digitized and supplied the font data. |
fmly |
The name of the typographic style (for example, `courier'). |
wght |
The weight of the font, or its nominal blackness, the degree of boldness or thickness of its characters. Values include `heavy', `bold', `medium', `light', and `thin'. |
slant |
The posture of the font, usually `r' (for `roman', or upright), `i' (`italic', slanted upward to the right and differing in shape from the roman counterpart), or `o' (`oblique', slanted but with the shape of the roman counterpart). |
swdth |
The proportionate width of the characters in the font, or its nominal width, such as `normal', `condensed', `extended', `narrow', and `wide'. |
adstyl |
Any additional style descriptions the particular font takes, such as `serif' (fonts that have small strokes drawn on the ends of each line in the character) or `sans serif' (fonts that omit serifs). |
pxlsz |
The height, in pixels, of the type. Also called body size. |
ptsz |
The height, in points, of the type. |
resx |
The horizontal screen resolution the font was designed for, in dpi ("dots per inch"). |
resy |
The vertical screen resolution the font was designed for, in dpi. |
spc |
The kind of spacing used by the font (its escapement class); either `p' (a proportional font containing characters with varied spacing), `m' (a monospaced font containing characters with constant spacing), or `c' (a character cell font containing characters with constant spacing and constant height). |
avgwdth |
The average width of the characters used in the font, in 1/10th pixel units. |
rgstry |
The international standards body, or registry, that owns the encoding. |
encdng |
The registered name of this character set, or its encoding. |
X font names can be long and difficult to type; to make it easier, use
the xfontsel
client, an interactive tool for picking X fonts and
getting their X font names.
When you start xfontsel
, it looks like this (the window frame
will differ depending on your window manager):
The row of buttons are pull-down menus containing options available on your system for each field in the X font name. Use the mouse to select items from each menu, and the X font you have selected is shown in the main window. Above it is written its X font name.
select
.
This example makes the X font name the X selection, which makes it possible to paste the X font name to a command line or into another window (see Pasting Text).
Use xlsfonts
to list the X font families, sizes, and weights
available on your system. Supply a pattern in quotes as an argument, and
it outputs the names of all X fonts installed on the system that match
that pattern; by default, it lists all fonts.
$ xlsfonts [RET]
$ xlsfonts '*rea*' [RET]
$ xlsfonts '*bold*' [RET]
NOTE: This is not a way to display the characters in a
font; for that, use xfd
, described next. Furthermore, to
browse through available X fonts, you want to use
xfontsel
, as in the previous recipe.
Use the xfd
tool ("X font display") to display all of the
characters in a given X font. Give the X font name you want to display
in quotes as an argument to the `-fn' option.
$ xfd -fn '-*-courier-medium-r-normal--*-100-*-*-*-*-iso8859-1' [RET]
See Specifying Window Font for how to specify the
font to use in an xterm
window in X. The xterm
tool is
usually used to run a shell while in X, and many people like to specify
which font is used for this window.
To resize the current font when the xterm
is running, press and
hold [CTRL] and right-click anywhere in the xterm
window. A
menu will appear that gives you the size options, from Unreadable
and Tiny
to Huge
. To resize the font to its original size,
choose Default
.
Console fonts are screen fonts for displaying text on the Linux console (and not in the X Window System).
Console fonts are stored in the `/usr/share/consolefonts' directory as compressed files; to install new console fonts, have the system administrator make a `/usr/local/share/consolefonts' directory and put the font files in there.
These recipes show how to set the console font, and how to display a table containing all of the characters in the current font.
Use consolechars
to set the current console font; give the base
file name of a console font as an argument to the `-f' option.
scrawl_w
font, type:
$ consolechars -f scrawl_w [RET]
Some font files contain more than one height (or size) of the font. If a
font contains more than one encoding for different heights, give the
height to use as an argument to the `-H' option. (If you try to do
it without the option anyway, consolechars
will output a list of
available sizes.)
Common console font heights include 8 (for 8x8 fonts), 14 (for 8x14 fonts), and 16 (for 8x16 fonts).
sc
font, type:
$ consolechars -H 8 -f sc [RET]
Use showcfont
to display all of the characters in the current
console font.
$ showcfont [RET]
Text fonts are fonts created from the arrangement of ASCII characters on the screen; they are often seen in Usenet articles and email messages, included as decorative or title elements in text files, and used for printing simple banners or posters on a printer.
The making of "fonts" (and even pictures) from the arrangement of ASCII characters is known as ascii art. The following recipes describe methods of outputting text in these kind of fonts.
The figlet
filter outputs text in a given text font. Give the
text to output as an argument, quoting text containing shell
metacharacters (see Passing Special Characters to Commands).
figlet
font,
type:
$ figlet news alert [RET]
This command outputs the following:
_ _ _ __ _____ _____ __ _| | ___ _ __| |_ | '_ \ / _ \ \ /\ / / __| / _` | |/ _ \ '__| __| | | | | __/\ V V /\__ \ | (_| | | __/ | | |_ |_| |_|\___| \_/\_/ |___/ \__,_|_|\___|_| \__|
Fonts for figlet
are kept in the `/usr/lib/figlet'
directory; use the `-f' option followed by the base name of the
font file (without the path or extension) to use that font.
To output the contents of a text file with a figlet
font, use
cat
to output the contents of a file and pipe the output to
figlet
.
$ cat poster | figlet -f bubble [RET]
NOTE: The `bubble' font is installed at `/usr/lib/figlet/bubble.flf'.
The easiest way to print a long, vertical banner of text on a Linux
system is with the old UNIX banner
tool.
Quote a text message as an argument, and banner
sends a large,
vertical "banner" of the message to the standard output. The message
itself is output in a "font" composed of ASCII text characters,
similar to those used by figlet
, except that the message is
output vertically for printing, and you can't change the font. To send
the output of banner
to the printer, pipe it to lpr
.
$ banner 'Happy Birthday Susan' [RET]
$ banner 'Happy Birthday Susan' | lpr [RET]
Unfortunately, the breadth of characters that banner
understands
is a bit limited -- the following characters can't be used in a
banner
message:
< > [ ] \ ^ _ { } | ~
To make a banner of the contents of a text file, send its contents to
banner
by redirecting standard input (see Redirecting Input to a File).
$ banner < /etc/hostname [RET]
The default width of a banner is 132 text columns; you can specify a different width by specifying the width to use as an argument to the `-w' option. If you give the `-w' option without a number, banner outputs at 80 text columns.
$ banner -w 23 'Happy Birthday Susan' [RET]
$ banner -w 'Happy Birthday Susan' [RET]
NOTE: A method of making a horizontal text banner with
figlet
is described in Outputting Text in Landscape Orientation.
The following table describes some of the other font tools available for Linux.
TOOL | DESCRIPTION |
cse |
The Linux Console Font Editor, cse , is an older console font
editor.
WWW: http://www.ibiblio.org/pub/Linux/system/keyboards/ |
dtm |
The Definitive Type Manager is a tool for adding and removing Adobe
Type 1 fonts to and from your system.
Debian: `dtm' |
fonter |
Fonter is a console font editor; use it to make and edit console
fonts.
Debian: `fonter' |
gfont |
The gfont tool creates a GIF image of text rendered in a
TeX font.
Debian: `gfont' WWW: http://www.engelschall.com/sw/gfont/ |
gfontview |
This is a tool for viewing Adobe Type 1 and TrueType fonts.
Debian: `gfontview' |
[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]