Наши друзья и партнеры

купить дешевый 
компьютер родом из Dhgate.com

Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17. Fonts

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 section Reading System Documentation and Help Files).

17.1 X Fonts  Fonts in X.
17.2 Console Fonts  Fonts in the console.
17.3 Text Fonts  Fonts made of ASCII text characters.
17.4 Other Font Tools  Other kinds of fonts.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.1 X Fonts

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 a 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:


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.

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.

17.1.1 Selecting an X Font Name  Selecting an X font name.
17.1.2 Listing Available X Fonts  Listing available fonts.
17.1.3 Displaying the Characters in an X Font  Viewing a character set in a font.
17.1.4 Resizing the Xterm Font  Setting the font in an Xterm.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.1.1 Selecting an X Font Name

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.

  • To make the X font name the X selection, click the mouse on the button labeled 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 section Pasting Text).

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.1.2 Listing Available X Fonts

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.

  • To list all the X fonts on the system, type:
    $ xlsfonts RET

  • To list all the X fonts on the system whose name contains the text `rea', type:
    $ xlsfonts '*rea*' RET

  • To list all the bold X fonts on the system, type:

    $ 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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.1.3 Displaying the Characters in an X Font

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.

  • To display the characters in a medium Courier X font, type:
$ xfd -fn '-*-courier-medium-r-normal--*-100-*-*-*-*-iso8859-1' RET

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.1.4 Resizing the Xterm Font

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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.2 Console Fonts

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.

17.2.1 Setting the Console Font  Setting the console font.
17.2.2 Displaying the Characters in a Console Font  Showing all characters in the console font.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.2.1 Setting the Console 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.

  • To set the console font to the 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).

  • To set the console font to the 8x8 size sc font, type:

    $ consolechars -H 8 -f sc RET

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.2.2 Displaying the Characters in a Console Font

Use showcfont to display all of the characters in the current console font.

  • To list all of the characters in the current console font, type:

    $ showcfont RET

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.3 Text Fonts

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.

17.3.1 Horizontal Text Fonts  Horizontal text fonts.
17.3.2 Making a Text Banner  Making text banners.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.3.1 Horizontal Text 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 section Passing Special Characters to Commands).

  • To output the text `news alert' in the default 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.

  • To output the text of the file `poster' in the figlet `bubble' font, type:

    $ cat poster | figlet -f bubble RET

NOTE: The `bubble' font is installed at `/usr/lib/figlet/bubble.flf'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.3.2 Making a Text Banner

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.

  • To make a banner saying `Happy Birthday Susan', type:
    $ banner 'Happy Birthday Susan' RET

  • To print a banner saying `Happy Birthday Susan' to the default printer, type:

    $ 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 section Redirecting Input to a File).

    To make a banner of the contents of the file `/etc/hostname', type:
    $ 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.

  • To make a banner containing the text `Happy Birthday Susan' at a width of 23 text columns, type:
    $ banner -w 23 'Happy Birthday Susan' RET

  • To make a banner containing the text `Happy Birthday Susan' at a width of 80 text columns, type:

    $ 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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.4 Other Font Tools

The following table describes some of the other font tools available for Linux.

cse The Linux Console Font Editor, cse, is an older console font editor. {@sf{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. {@sf{Debian}}: `dtm'
fonter Fonter is a console font editor; use it to make and edit console fonts. {@sf{Debian}}: `fonter'
gfont The gfont tool creates a GIF image of text rendered in a TeX font. {@sf{Debian}}: `gfont' {@sf{WWW}}: http://www.engelschall.com/sw/gfont/
gfontview This is a tool for viewing Adobe Type 1 and TrueType fonts. {@sf{Debian}}: `gfontview'

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

Если вам понравилась статья, поделитесь ею с друзьями: