1
1
@c This is part of the Emacs manual.
2
2
@c Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004,
3
@c 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
3
@c 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4
4
@c See file emacs.texi for copying conditions.
5
5
@node International, Major Modes, Frames, Top
6
6
@chapter International Character Set Support
103
103
* Fontsets:: Fontsets are collections of fonts
104
104
that cover the whole spectrum of characters.
105
105
* Defining Fontsets:: Defining a new fontset.
106
* Modifying Fontsets:: Modifying an existing fontset.
106
107
* Undisplayable Characters:: When characters don't display.
107
108
* Unibyte Mode:: You can pick one European character set
108
109
to use without multibyte characters.
1333
1334
A font typically defines shapes for a single alphabet or script.
1334
1335
Therefore, displaying the entire range of scripts that Emacs supports
1335
1336
requires a collection of many fonts. In Emacs, such a collection is
1336
called a @dfn{fontset}. A fontset is defined by a list of fonts, each
1337
assigned to handle a range of character codes.
1337
called a @dfn{fontset}. A fontset is defined by a list of font specs,
1338
each assigned to handle a range of character codes, and may fall back
1339
on another fontset for characters which are not covered by the fonts
1339
1342
Each fontset has a name, like a font. However, while fonts are
1340
1343
stored in the system and the available font names are defined by the
1347
1350
installation instructions have information on additional font
1350
Emacs creates two fontsets automatically: the @dfn{standard fontset}
1351
and the @dfn{startup fontset}. The standard fontset is most likely to
1352
have fonts for a wide variety of non-@acronym{ASCII} characters;
1353
however, this is not the default for Emacs to use. (By default, Emacs
1354
tries to find a font that has bold and italic variants.) You can
1355
specify use of the standard fontset with the @samp{-fn} option. For
1353
Emacs creates three fontsets automatically: the @dfn{standard
1354
fontset}, the @dfn{startup fontset} and the @dfn{default fontset}.
1355
The default fontset is most likely to have fonts for a wide variety of
1356
non-@acronym{ASCII} characters and is the default fallback for the
1357
other two fontsets, and if you set a default font rather than fontset.
1358
However it does not specify font family names, so results can be
1359
somewhat random if you use it directly. You can specify use of a
1360
specific fontset with the @samp{-fn} option. For example,
1359
1363
emacs -fn fontset-standard
1363
1367
You can also specify a fontset with the @samp{Font} resource (@pxref{X
1370
If no fontset is specified for use, then Emacs uses an
1371
@acronym{ASCII} font, with @samp{fontset-default} as a fallback for
1372
characters the font does not cover. The standard fontset is only used if
1373
explicitly requested, despite its name.
1366
1375
A fontset does not necessarily specify a font for every character
1367
1376
code. If a fontset specifies no font for a certain character, or if it
1368
1377
specifies a font that does not exist on your system, then it cannot
1373
1382
@section Defining fontsets
1375
1384
@vindex standard-fontset-spec
1385
@vindex w32-standard-fontset-spec
1386
@vindex ns-standard-fontset-spec
1376
1387
@cindex standard fontset
1377
Emacs creates a standard fontset automatically according to the value
1388
When running on X, Emacs creates a standard fontset automatically according to the value
1378
1389
of @code{standard-fontset-spec}. This fontset's name is
1385
1396
or just @samp{fontset-standard} for short.
1398
On GNUstep and Mac, fontset-standard is created using the value of
1399
@code{ns-standard-fontset-spec}, and on Windows it is
1400
created using the value of @code{w32-standard-fontset-spec}.
1387
1402
Bold, italic, and bold-italic variants of the standard fontset are
1388
1403
created automatically. Their names have @samp{bold} instead of
1389
1404
@samp{medium}, or @samp{i} instead of @samp{r}, or both.
1391
1406
@cindex startup fontset
1392
If you specify a default @acronym{ASCII} font with the @samp{Font} resource or
1393
the @samp{-fn} argument, Emacs generates a fontset from it
1394
automatically. This is the @dfn{startup fontset} and its name is
1395
@code{fontset-startup}. It does this by replacing the @var{foundry},
1396
@var{family}, @var{add_style}, and @var{average_width} fields of the
1397
font name with @samp{*}, replacing @var{charset_registry} field with
1398
@samp{fontset}, and replacing @var{charset_encoding} field with
1399
@samp{startup}, then using the resulting string to specify a fontset.
1407
Emacs generates a fontset automatically, based on any default
1408
@acronym{ASCII} font that you specify with the @samp{Font} resource or
1409
the @samp{-fn} argument, or the default font that Emacs found when it
1410
started. This is the @dfn{startup fontset} and its name is
1411
@code{fontset-startup}. It does this by replacing the
1412
@var{charset_registry} field with @samp{fontset}, and replacing
1413
@var{charset_encoding} field with @samp{startup}, then using the
1414
resulting string to specify a fontset.
1401
1416
For instance, if you start Emacs this way,
1412
-*-*-medium-r-normal-*-14-140-*-*-*-*-fontset-startup
1427
-*-courier-medium-r-normal-*-14-140-*-*-*-*-fontset-startup
1430
The startup fontset will use the font that you specify or a variant
1431
with a different registry and encoding for all the characters which
1432
are supported by that font, and fallback on @samp{fontset-default} for
1415
1435
With the X resource @samp{Emacs.Font}, you can specify a fontset name
1416
1436
just like an actual font name. But be careful not to specify a fontset
1417
1437
name in a wildcard resource like @samp{Emacs*Font}---that wildcard
1497
1517
@xref{Font X}, for more information about font naming in X.
1519
@node Modifying Fontsets
1520
@section Modifying Fontsets
1521
@cindex fontsets, modifying
1522
@findex set-fontset-font
1524
Fontsets do not always have to be created from scratch. If only
1525
minor changes are required it may be easier to modify an existing
1526
fontset. Modifying @samp{fontset-default} will also affect other
1527
fontsets that use it as a fallback, so can be an effective way of
1528
fixing problems with the fonts that Emacs chooses for a particular
1531
Fontsets can be modified using the function @code{set-fontset-font},
1532
specifying a character, a charset, a script, or a range of characters
1533
to modify the font for, and a font-spec for the font to be used. Some
1537
;; Use Liberation Mono for latin-3 charset.
1538
(set-fontset-font "fontset-default" 'iso-8859-3 "Liberation Mono")
1540
;; Prefer a big5 font for han characters
1541
(set-fontset-font "fontset-default" 'han (font-spec :registry "big5")
1544
;; Use DejaVu Sans Mono as a fallback in fontset-startup before
1545
;; resorting to fontset-default.
1546
(set-fontset-font "fontset-startup" nil "DejaVu Sans Mono" nil 'append)
1548
;; Use MyPrivateFont for the Unicode private use area.
1549
(set-fontset-font "fontset-default" '(#xe000 . #xf8ff) "MyPrivateFont")
1499
1554
@node Undisplayable Characters
1500
1555
@section Undisplayable Characters