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:
default-frame-alistto specify the
fontparameter (see Frame Parameters), like this:
(add-to-list 'default-frame-alist '(font . 'DejaVu Sans Mono-10'))
This makes the font the default on all graphical frames created after restarting Emacs with that init file.
emacs.font: DejaVu Sans Mono-12
You must restart X, or use the
xrdb command, for the X
resources file to take effect. See Resources. Do not quote
font names in X resource files.
t(the default is
nil). For this to work, Emacs must have been compiled with support for Gsettings (or the older Gconf).
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 ‘italic’, ‘oblique’, or ‘roman’.
One of ‘light’, ‘medium’, ‘demibold’, ‘bold’ or ‘black’.
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 ‘condensed’, ‘normal’, or ‘expanded’.
One of ‘monospace’, ‘proportional’, ‘dual-width’, or ‘charcell’.
Here are some examples of Fontconfig patterns:
Monospace Monospace-12 Monospace-12:bold DejaVu Sans Mono:bold:italic Monospace-12:weight=bold:slant=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 fontname[-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]
where 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:
Here are some examples of GTK font patterns:
Monospace 12 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., ‘courier’).
The font weight—normally either ‘bold’, ‘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 ‘normal’, ‘condensed’, ‘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, height and 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 horiz.
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 ‘iso8859’ for registry and
‘1’ for encoding.
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:
fc-list :spacing=mono fc-list :spacing=charcell
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,
xfd command. For example:
xfd -fn 6x13
displays the entire font ‘6x13’.
While running Emacs, you can also set the font of a specific kind of text (see Faces), or a particular frame (see Frame Parameters).