[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

38.12.5 Font Selection

Selecting a font means mapping the specified face attributes for a character to a font that is available on a particular display. The face attributes, as determined by face merging, specify most of the font choice, but not all. Part of the choice depends on what character it is.

If the face specifies a fontset name, that fontset determines a pattern for fonts of the given charset. If the face specifies a font family, a font pattern is constructed.

Emacs tries to find an available font for the given face attributes and character's registry and encoding. If there is a font that matches exactly, it is used, of course. The hard case is when no available font exactly fits the specification. Then Emacs looks for one that is “close”—one attribute at a time. You can specify the order to consider the attributes. In the case where a specified font family is not available, you can specify a set of mappings for alternatives to try.

Variable: face-font-selection-order

This variable specifies the order of importance of the face attributes :width, :height, :weight, and :slant. The value should be a list containing those four symbols, in order of decreasing importance.

Font selection first finds the best available matches for the first attribute listed; then, among the fonts which are best in that way, it searches for the best matches in the second attribute, and so on.

The attributes :weight and :width have symbolic values in a range centered around normal. Matches that are more extreme (farther from 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.

The default is (:width :height :weight :slant), which means first find the fonts closest to the specified :width, then—among the fonts with that width—find a best match for the specified font height, and so on.

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 :slant before :height, the italic face will use an italic font, even if its height is not quite right.

Variable: face-font-family-alternatives

This variable lets you specify alternative font families to try, if a given family is specified and doesn't exist. Each element should have this form:

 
(family alternate-families…)

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.

Variable: face-font-registry-alternatives

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:

 
(registry alternate-registries…)

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, since the use of too many or too big scalable fonts can crash XFree86 servers.

Variable: scalable-fonts-allowed

This variable controls which scalable fonts to use. A value of nil, the default, means do not use scalable fonts. t 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 '("muleindian-2$"))

allows the use of scalable fonts with registry muleindian-2.

Variable: face-font-rescale-alist

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.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.