

Defining fontsets

Emacs creates a standard fontset automatically according to the value of standard-fontset-spec. This fontset's name is


or just `fontset-standard' for short.

Bold, italic, and bold-italic variants of the standard fontset are created automatically. Their names have `bold' instead of `medium', or `i' instead of `r', or both.

If you specify a default ASCII font with the `Font' resource or the `-fn' argument, Emacs generates a fontset from it automatically. This is the startup fontset and its name is fontset-startup. It does this by replacing the foundry, family, add_style, and average_width fields of the font name with `*', replacing charset_registry field with `fontset', and replacing charset_encoding field with `startup', then using the resulting string to specify a fontset.

For instance, if you start Emacs this way,

emacs -fn "*courier-medium-r-normal--14-140-*-iso8859-1"

Emacs generates the following fontset and uses it for the initial X window frame:


With the X resource `Emacs.Font', you can specify a fontset name just like an actual font name. But be careful not to specify a fontset name in a wildcard resource like `Emacs*Font'---that wildcard specification applies to various other purposes, such as menus, and menus cannot handle fontsets.

You can specify additional fontsets using X resources named `Fontset-n', where n is an integer starting from 0. The resource value should have this form:

fontpattern, [charsetname:fontname]...

fontpattern should have the form of a standard X font name, except for the last two fields. They should have the form `fontset-alias'.

The fontset has two names, one long and one short. The long name is fontpattern. The short name is `fontset-alias'. You can refer to the fontset by either name.


For the other character sets, Emacs chooses a font based on fontpattern. It replaces `fontset-alias' with values that describe the character set. For the ASCII character font, `fontset-alias' is replaced with `ISO8859-1'.


Thus if fontpattern is this,


the font specification for ASCII characters would be this:


and the font specification for Chinese GB2312 characters would be this:


You may not have any Chinese font matching the above font specification. Most X distributions include only Chinese fonts that have `song ti' or `fangsong ti' in family field. In such a case, `Fontset-n' can be specified as below:


Then, the font specifications for all but Chinese GB2312 characters have `fixed' in the family field, and the font specification for Chinese GB2312 characters has a wild card `*' in the family field.

The function that processes the fontset resource value to create the fontset is called create-fontset-from-fontset-spec. You can also call this function explicitly to create a fontset.

See section Font Specification Options, for more information about font naming in X.
