By default, Emacs displays text on graphical displays using a 10-point monospace font, and the font size can be changed interactively (see Text Scale).
There are several different ways to specify a different font:
Click on ‘
Set Default Font’ in the ‘
Options’ menu. This makes the selected font the default on all existing graphical frames. To save this for future sessions, click on ‘
Save Options’ in the ‘
Add a line to your init file, modifying the variable
default-frame-alistto specify the
fontparameter (see Frame Parameters), like this:
'(font . "DejaVu Sans Mono-10"))
This makes the font the default on all graphical frames created after restarting Emacs with that init file.
Add an ‘
emacs.font’ X resource setting to your X resource file, like this:
emacs.font: DejaVu Sans Mono-12
You must restart X, or use the
xrdbcommand, for the X resources file to take effect. See Resources. Do not quote font names in X resource files.
If you are running Emacs on the GNOME desktop, you can tell Emacs to use the default system font by setting the variable
t(the default is
nil). For this to work, Emacs must have been compiled with support for Gsettings (or the older Gconf).
Use the command line option ‘
-fn’ (or ‘
--font’). See Font X.
To check what font you’re currently using, the
C-u C-x = command can be helpful. It describes the character at point, and names the font that it’s rendered in.
There are four different ways to express a font name. The first is to use a Fontconfig pattern. Fontconfig patterns have the following form:
Within this format, any of the elements in brackets may be omitted. Here,
fontname is the family name of the font, such as ‘
Monospace’ or ‘
DejaVu Sans Mono’;
fontsize is the point size of the font (one printer’s point is about 1/72 of an inch); and the ‘
name=values’ entries specify settings such as the slant and weight of the font. Each
values may be a single value, or a list of values separated by commas. In addition, some property values are valid with only one kind of property name, in which case the ‘
name=’ part may be omitted.
Here is a list of common font properties:
One of ‘
oblique’, or ‘
One of ‘
bold’ or ‘
Some fonts define special styles which are a combination of slant and weight. For instance, ‘
Dejavu Sans’ defines the ‘
book’ style, which overrides the slant and weight properties.
One of ‘
normal’, or ‘
One of ‘
dual-width’, or ‘
Here are some examples of Fontconfig patterns:
DejaVu Sans Mono:bold:italic
For a more detailed description of Fontconfig patterns, see the Fontconfig manual, which is distributed with Fontconfig and available online at https://fontconfig.org/fontconfig-user.html.
On MS-Windows, only the subset of the form
fontsize] is supported for all fonts; the full Fontconfig pattern might not work for all of them.
The second way to specify a font is to use a GTK font pattern. These have the syntax
fontname [properties] [fontsize]
fontname is the family name,
properties is a list of property values separated by spaces, and
fontsize is the point size. The properties that you may specify for GTK font patterns are as follows:
- Slant properties: ‘
Italic’ or ‘
Oblique’. If omitted, the default (roman) slant is implied.
- Weight properties: ‘
Semi-bold’, or ‘
Ultra-light’. If omitted, ‘
Medium’ weight is implied.
- Width properties: ‘
Semi-Condensed’ or ‘
Condensed’. If omitted, a default width is used.
Here are some examples of GTK font patterns:
Monospace Bold Italic 12
On MS-Windows, only the subset
fontname is supported.
The third way to specify a font is to use an XLFD (X Logical Font Description). This is the traditional method for specifying fonts under X, and is also supported on MS-Windows. Each XLFD consists of fourteen words or numbers, separated by dashes, like this:
A wildcard character (‘
*’) in an XLFD matches any sequence of characters (including none), and ‘
?’ matches any single character. However, matching is implementation-dependent, and can be inaccurate when wildcards match dashes in a long name. For reliable results, supply all 14 dashes and use wildcards only within a field. Case is insignificant in an XLFD. The syntax for an XLFD is as follows:
The entries have the following meanings:
The name of the font manufacturer.
The name of the font family (e.g., ‘
The font weight—normally either ‘
medium’ or ‘
light’. Some font names support other values.
The font slant—normally ‘
r’ (roman), ‘
i’ (italic), ‘
o’ (oblique), ‘
ri’ (reverse italic), or ‘
ot’ (other). Some font names support other values.
The font width—normally ‘
semicondensed’, or ‘
extended’. Some font names support other values.
An optional additional style name. Usually it is empty—most XLFDs have two hyphens in a row at this point. The style name can also specify a two-letter ISO-639 language name, like ‘
ja’ or ‘
ko’; some fonts that support CJK scripts have that spelled out in the style name part.
The font height, in pixels.
The font height on the screen, measured in tenths of a printer’s point. This is the point size of the font, times ten. For a given vertical resolution,
pixels are proportional; therefore, it is common to specify just one of them and use ‘
*’ for the other.
The horizontal resolution, in pixels per inch, of the screen for which the font is intended.
The vertical resolution, in pixels per inch, of the screen for which the font is intended. Normally the resolution of the fonts on your system is the right value for your screen; therefore, you normally specify ‘
*’ for this and
This is ‘
m’ (monospace), ‘
p’ (proportional) or ‘
c’ (character cell).
The average character width, in pixels, multiplied by ten.
The X font character set that the font depicts. (X font character sets are not the same as Emacs character sets, but they are similar.) You can use the
xfontsel program to check which choices you have. Normally you should use ‘
registry and ‘
The fourth and final method of specifying a font is to use a font nickname. Certain fonts have shorter nicknames, which you can use instead of a normal font specification. For instance, ‘
6x13’ is equivalent to
This form is not supported on MS-Windows.
On X, Emacs recognizes two types of fonts: client-side fonts, which are provided by the Xft and Fontconfig libraries, and server-side fonts, which are provided by the X server itself. Most client-side fonts support advanced font features such as antialiasing and subpixel hinting, while server-side fonts do not. Fontconfig and GTK patterns match only client-side fonts.
You will probably want to use a fixed-width default font—that is, a font in which all characters have the same width. For Xft and Fontconfig fonts, you can use the
fc-list command to list the available fixed-width fonts, like this:
For server-side X fonts, you can use the
xlsfonts program to list the available fixed-width fonts, like this:
xlsfonts -fn '*x*' | grep -E '^[0-9]+x[0-9]+'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-m*'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-c*'
Any font with ‘
m’ or ‘
c’ in the
spacing field of the XLFD is a fixed-width font. To see what a particular font looks like, use the
xfd command. For example:
xfd -fn 6x13
displays the entire font ‘