Go to the first, previous, next, last section, table of contents.


Using Multiple Typefaces

When using Emacs with X, you can set up multiple styles of displaying characters. The aspects of style that you can control are the type font, the foreground color, the background color, and whether to underline. Emacs on MS-DOS supports faces partially by letting you control the foreground and background colors of each face (see section Emacs and MS-DOS).

The way you control display style is by defining named faces. Each face can specify a type font, a foreground color, a background color, and an underline flag; but it does not have to specify all of them. Then by specifying the face or faces to use for a given part of the text in the buffer, you control how that text appears.

The style of display used for a given character in the text is determined by combining several faces. Any aspect of the display style that isn't specified by overlays or text properties comes from the frame itself.

Enriched mode, the mode for editing formatted text, includes several commands and menus for specifying faces. See section Faces in Formatted Text, for how to specify the font for text in the buffer. See section Colors in Formatted Text, for how to specify the foreground and background color.

To alter the appearance of a face, use the customization buffer. See section Customizing Faces. You can also use X resources to specify attributes of particular faces (see section X Resources).

To see what faces are currently defined, and what they look like, type M-x list-faces-display. It's possible for a given face to look different in different frames; this command shows the appearance in the frame in which you type it. Here's a list of the standardly defined faces:

default
This face is used for ordinary text that doesn't specify any other face.
modeline
This face is used for mode lines. By default, it's set up as the inverse of the default face. See section Variables Controlling Display.
highlight
This face is used for highlighting portions of text, in various modes.
region
This face is used for displaying a selected region (when Transient Mark mode is enabled--see below).
secondary-selection
This face is used for displaying a secondary selection (see section Secondary Selection).
bold
This face uses a bold variant of the default font, if it has one.
italic
This face uses an italic variant of the default font, if it has one.
bold-italic
This face uses a bold italic variant of the default font, if it has one.
underline
This face underlines text.

When Transient Mark mode is enabled, the text of the region is highlighted when the mark is active. This uses the face named region; you can control the style of highlighting by changing the style of this face (see section Customizing Faces). See section Transient Mark Mode, for more information about Transient Mark mode and activation and deactivation of the mark.

One easy way to use faces is to turn on Font Lock mode. This minor mode, which is always local to a particular buffer, arranges to choose faces according to the syntax of the text you are editing. It can recognize comments and strings in most languages; in several languages, it can also recognize and properly highlight various other important constructs. See section Font Lock mode, for more information about Font Lock mode and syntactic highlighting.

You can print out the buffer with the highlighting that appears on your screen using the command ps-print-buffer-with-faces. See section Postscript Hardcopy.


Go to the first, previous, next, last section, table of contents.