F.5 Specifying Fonts on Mac
It is rare that you need to specify a font name in Emacs; usually
you specify face attributes instead. For example, you can use 14pt
Courier by customizing the default face attributes for all frames:
(set-face-attribute 'default nil :family "courier" :height 140)
Alternatively, an interactive one is also available
(see Face Customization).
But when you do need to specify a font name in Emacs on Mac, use a
standard X font name:
-maker-family-weight-slant-widthtype-style...
...-pixels-height-horiz-vert-spacing-width-charset
See Font X. Wildcards are supported as they are on X.
Native Apple fonts in Mac Roman encoding has maker name apple
and charset mac-roman
. For example 12-point Monaco can be
specified by the name ‘-apple-monaco-*-12-*-mac-roman’. When
using a particular size of scalable fonts, it must be specified in a
format containing 14 ‘-’s like
‘-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman’.
You can specify a mac-roman
font for ASCII
characters like
(add-to-list
'default-frame-alist
'(font . "-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman"))
but that does not extend to ISO-8859-1: specifying a mac-roman
font for Latin-1 characters introduces wrong glyphs.
Native Apple Traditional Chinese, Simplified Chinese, Japanese,
Korean, Central European, Cyrillic, Symbol, and Dingbats fonts have
charsets ‘big5-0’, ‘gb2312.1980-0’,
‘jisx0208.1983-sjis’ and ‘jisx0201.1976-0’,
‘ksc5601.1989-0’, ‘mac-centraleurroman’,
‘mac-cyrillic’, ‘mac-symbol’, and ‘mac-dingbats’,
respectively.
Since Emacs as of the current version uses QuickDraw Text routines
for drawing texts, only characters in the charsets listed above can be
displayed with the OS-bundled fonts, even if other applications that
use ATSUI or Cocoa can display variety of characters with
them.
The use of create-fontset-from-fontset-spec
(see Defining Fontsets) for defining fontsets often results in wrong ones
especially when using only OS-bundled fonts. The recommended way is
to create a fontset using create-fontset-from-mac-roman-font
:
(create-fontset-from-mac-roman-font
"-apple-courier-medium-r-normal--13-*-*-*-*-*-mac-roman"
nil "foo")
and then optionally specifying Chinese, Japanese, or Korean font
families using set-fontset-font
:
(set-fontset-font "fontset-foo"
'chinese-gb2312 '("song" . "gb2312.1980-0"))
Single-byte fonts converted from GNU fonts in BDF format, which are not
in the Mac Roman encoding, have foundry, family, and character sets
encoded in the names of their font suitcases. E.g., the font suitcase
‘ETL-Fixed-ISO8859-1’ contains fonts which can be referred to by
the name ‘-ETL-fixed-*-iso8859-1’.
Emacs uses the QuickDraw text rendering by default. On Mac OS X
10.2 and later, it can be changed so that it uses the Quartz 2D text
rendering (aka CG text rendering) by setting
mac-allow-anti-aliasing
to t
. However, it is reported
to sometimes leave some garbages.