Before Emacs can draw a character on a graphical display, it must
select a font for that character20. See Fonts in The GNU Emacs Manual. Normally,
Emacs automatically chooses a font based on the faces assigned to that
character—specifically, the face attributes
:width (see Face Attributes). The choice of font also depends on the character to be
displayed; some fonts can only display a limited set of characters.
If no available font exactly fits the requirements, Emacs looks for
the closest matching font. The variables in this section
control how Emacs makes this selection.
If a given family is specified but does not exist, this variable specifies alternative font families to try. Each element should have this form:
If family is specified but not available, Emacs will try the other families given in alternate-families, one by one, until it finds a family that does exist.
If there is no font that exactly matches all desired face attributes
this variable specifies the order in which these attributes should be
considered when selecting the closest matching font. The value should
be a list containing those four attribute symbols, in order of
decreasing importance. The default is
(:width :height :weight
Font selection first finds the best available matches for the first attribute in the list; then, among the fonts which are best in that way, it searches for the best matches in the second attribute, and so on.
:width have symbolic values in
a range centered around
normal. Matches that are more extreme
normal) are somewhat preferred to matches that are
less extreme (closer to
normal); this is designed to ensure that
non-normal faces contrast with normal ones, whenever possible.
One example of a case where this variable makes a difference is when the
default font has no italic equivalent. With the default ordering, the
italic face will use a non-italic font that is similar to the
default one. But if you put
italic face will use an italic font, even if its height is not
This variable lets you specify alternative font registries to try, if a given registry is specified and doesn’t exist. Each element should have this form:
If registry is specified but not available, Emacs will try the other registries given in alternate-registries, one by one, until it finds a registry that does exist.
Emacs can make use of scalable fonts, but by default it does not use them.
This variable controls which scalable fonts to use. A value of
nil, the default, means do not use scalable fonts.
means to use any scalable font that seems appropriate for the text.
Otherwise, the value must be a list of regular expressions. Then a scalable font is enabled for use if its name matches any regular expression in the list. For example,
(setq scalable-fonts-allowed '("iso10646-1$"))
allows the use of scalable fonts with registry
This variable specifies scaling for certain faces. Its value should be a list of elements of the form
(fontname-regexp . scale-factor)
If fontname-regexp matches the font name that is about to be used, this says to choose a larger similar font according to the factor scale-factor. You would use this feature to normalize the font size if certain fonts are bigger or smaller than their nominal heights and widths would suggest.
In this context, the term font has nothing to do with Font Lock (see Font Lock Mode).