Fonts in Emacs 22 and earlier are named using the X Logical Font Description (XLFD) format. Emacs on Windows ignores many of the fields, and populates them with * when listing fonts. Former maintainer Andrew Innes wrote this explanation of what each field in the font string means and how Emacs treated them back in 19.34. Since then, multilingual support and a redisplay overhaul to support variable width fonts have changed things slightly; more character sets are recognized (and the old pseudo character sets are deprecated), and the resolution fields are used to calculate the difference between point and pixel sizes, but normally you should leave these at the system default. The foundry field is also populated with an indication of whether the font is outline (.TTF, .ATM) or raster (.FON) based when fonts are listed, which may let you differentiate between two fonts with the same name and different technologies.
From Emacs 23, the preferred font name format will be moving to the simpler and more flexible fontconfig format. XLFD names will continue to be supported for backward compatibility.
XLFD: -*-Courier New-normal-r-*-*-13-*-*-*-c-*-iso8859-1 Fontconfig: Courier New-13
To find the XFLD name for a font, you can execute the following in the *scratch* buffer by pressing C-j at the end of the line:
(w32-select-font nil t)
To see a complete list of fonts, execute the following in the *scratch* buffer by pressing C-x C-e at the end of the line:
(insert (prin1-to-string (x-list-fonts "*")))
The command line options and frame-parameters for changing the default font in Emacs are documented in the manual. Fonts can also be used when defining faces, though family and size are generally specified individually there. In addition, Emacs on Windows reads the registry to find X Resources. This is also documented in the manual.
Emacs will only use the italic (and bold) versions of a font automatically if it has the same width as the normal version. Many fonts have italic and bold versions that are slightly wider. It will also only use real bold and italic fonts by default, where other applications may use synthesized variations that are derived from the normal font. To enable more italic and bold fonts to be displayed, you can enable synthesized fonts and manually set the font for italic, bold and bold-italic as follows:
(setq w32-enable-synthesized-fonts t) (set-face-font 'italic "-*-Courier New-normal-i-*-*-11-*-*-*-c-*-iso8859-1") (set-face-font 'bold-italic "-*-Courier New-bold-i-*-*-11-*-*-*-c-*-iso8859-1")
To display all the languages that Emacs is capable of displaying, you will require the BDF fonts from the GNU intlfonts package. See How do I use bdf fonts with Emacs?.
For many languages, native truetype fonts are sufficient, and in Emacs 23 the need for BDF fonts will disappear for almost all languages. At the time of writing, some Arabic characters in the HELLO file still do not display with native fonts, because they are pre-composed characters from MULE character sets rather than standard Unicode Arabic, but all other characters are able to be displayed with appropriate truetype or opentype fonts.
Recent versions of Emacs display a large range of characters out of
the box, but if you are having problems with a particular character
set which you know you have fonts for, you can try defining a
new fontset with create-fontset-from-ascii-font
or
create-fontset-from-fontset-spec
.
(create-fontset-from-fontset-spec "-*-Courier New-normal-r-*-*-12-*-*-*-c-*-fontset-most, latin-iso8859-2:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-2, latin-iso8859-3:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-3, latin-iso8859-4:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-4, cyrillic-iso8859-5:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-5, greek-iso8859-7:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-7, latin-iso8859-9:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-9, japanese-jisx0208:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis, katakana-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis, latin-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis, japanese-jisx0208-1978:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis, korean-ksc5601:-*-Gulim-normal-r-*-*-12-*-*-*-c-*-ksc5601-*, chinese-gb2312:-*-MS Song-normal-r-*-*-12-*-*-*-c-*-gb2312-*, chinese-big5-1:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*, chinese-big5-2:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*" t)
In addition to the wide range of fonts that come with the language support packages of various components of Windows itself, GNU/Linux distributions these days come with a number of Free truetype fonts that cover a wide range of languages. The GNU intlfonts source distribution contains BDF fonts covering all of the languages that can be displayed by Emacs 22, and can be downloaded from ftp.gnu.org.
You probably only need to do this on the non-Unicode versions of Windows (95, 98 and ME), and even then, various Windows and Internet Explorer updates have made third party software unnecessary in most cases. If you are having trouble displaying text, try defining a fontset with the font for the languages that the third party software handles set to what that software expects (which may not be an appropriate font for that language, but the third party software is intercepting it and using a different font behind the scenes). See How do I get Emacs to display non-latin characters?.
In addition to defining a fontset with the expected font, you may also need to disable unicode output with:
(setq w32-enable-unicode-output nil)
Normally Emacs should initialize locale-coding-system
appropriately
based on your locale, which will let Emacs use font names in your local
language successfully.
To use bdf fonts with Emacs, you need to tell Emacs where the fonts are located, create fontsets for them, and then use them. We'll use the 16 dot international fonts from ftp.gnu.org/gnu/intlfonts as an example put together by Jason Rumney
Download 16dots.tar.gz and unpack it; I'll assume that they are in
c:\intlfonts. Then set w32-bdf-filename-alist
to the list of
fonts returned by using w32-find-bdf-fonts
to enumerate all of
the font files. It is a good idea to set the variable
bdf-directory-list
at the same time so ps-print
knows where
to find the fonts:
(setq bdf-directory-list '("c:/intlfonts/Asian" "c:/intlfonts/Chinese" "c:/intlfonts/Chinese-X" "c:/intlfonts/Ethiopic" "c:/intlfonts/European" "c:/intlfonts/Japanese" "c:/intlfonts/Japanese-X" "c:/intlfonts/Korean-X" "c:/intlfonts/Misc/")) (setq w32-bdf-filename-alist (w32-find-bdf-fonts bdf-directory-list))
Then create fontsets for the BDF fonts:
(create-fontset-from-fontset-spec "-*-fixed-medium-r-normal-*-16-*-*-*-c-*-fontset-bdf, japanese-jisx0208:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1983-*, katakana-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*, latin-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*, japanese-jisx0208-1978:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1978-*, thai-tis620:-misc-fixed-medium-r-normal--16-160-72-72-m-80-tis620.2529-1, lao:-misc-fixed-medium-r-normal--16-160-72-72-m-80-MuleLao-1, tibetan-1-column:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-80-MuleTibetan-1, ethiopic:-Admas-Ethiomx16f-Medium-R-Normal--16-150-100-100-M-160-Ethiopic-Unicode, tibetan:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-160-MuleTibetan-0")
Many of the international bdf fonts from gnu.org are type 0, and therefore need to be added to font-encoding-alist:
;; Need to add some fonts to font-encoding-alist since the bdf fonts ;; are type 0 not the default type 1. (setq font-encoding-alist (append '(("MuleTibetan-0" (tibetan . 0)) ("GB2312" (chinese-gb2312 . 0)) ("JISX0208" (japanese-jisx0208 . 0)) ("JISX0212" (japanese-jisx0212 . 0)) ("VISCII" (vietnamese-viscii-lower . 0)) ("KSC5601" (korean-ksc5601 . 0)) ("MuleArabic-0" (arabic-digit . 0)) ("MuleArabic-1" (arabic-1-column . 0)) ("MuleArabic-2" (arabic-2-column . 0))) font-encoding-alist))
You can now use the Emacs font menu (see How can I have Emacs use a font menu like on X?) to select the bdf: 16-dot medium fontset, or you can select it by setting the default font:
(set-frame-font "fontset-bdf")
Try loading the file etc/HELLO, and you should be able to see the various international fonts displayed (except for Hindi, which is not included in the 16-dot font distribution).
Place the following in your init file:
(setq w32-use-w32-font-dialog nil)
If you have set w32-use-w32-font-dialog to nil, you can add fonts to the font menu by changing `w32-fixed-font-alist'. For example:
(setq w32-fixed-font-alist (append w32-fixed-font-alist '(("Monotype.com" ("8" "-*-Monotype.com-normal-r-*-*-11-*-*-*-c-iso8859-1") ("9" "-*-Monotype.com-normal-r-*-*-12-*-*-*-c-iso8859-1") ("10" "-*-Monotype.com-normal-r-*-*-13-*-*-*-c-iso8859-1") ("11" "-*-Monotype.com-normal-r-*-*-15-*-*-*-c-iso8859-1")))))
There are a number of methods by which you can control automatic CR/LF translation in Emacs, a situation that reflects the fact that the default support was not very robust in the past. For a discussion of this issue, take a look at this collection of email messages on the topic.
For existing files, Emacs scans the file to determine the line ending convention as part of the same scan it does to determine the file encoding. Embedded Ctrl-M (ASCII 13) characters and inconsistent line ends can confuse the automatic scanning, and Emacs will present the file in Unix (LF) mode with the Ctrl-M characters displayed as ‘^M’. It does this to be safe, as no data loss will occur if the file is really binary and the Ctrl-M characters are significant.
The variable file-name-buffer-file-type-alist
holds a list of
filename patterns and their associated type; binary or text. Files marked
as binary will not have line-end detection performed on them, and instead
will always be displayed as is. With auto-detection in recent versions of
Emacs, this is seldom useful for existing files, but can still be used
to influence the choice of line ends for newly created files.
The variable untranslated-filesystem-list
defines whole
directory trees that should not have CR/LF autodetection performed on
them. The list can be manipulated with the functions
add-untranslated-filesystem
and
remove-untranslated-filesystem
. With auto-detection in
recent versions of Emacs, this is seldom useful for existing files,
but can still be used to influence the choice of line ends for newly
created files.