The most important info first. Here’s how to change the default font in your InitFile: use
M-x customize-face to customize the
S-down-mouse-1’ to see the font and fontset menu. Emacs starts with the startup fontset.
M-x describe-font’ to see the requested font and actual font being used.
‘doremi-font’in DoReMi to change the default font of a frame by cycling among the available fonts – just stop when you get to the font you want.
‘icicle-font’in Icicles to do the same thing (cycle among fonts) – but with the added benefit of completion, including regexp matching.
‘anything-select-xfont’to narrow the font list by typing some patterns.
To change the default font for new (non special-display) frames, put either of these in your init file:
(add-to-list 'default-frame-alist '(font .
(set-face-attribute 'default t :font
To change the default font for the current frame, as well as future frames, put either of these in your init file:
(set-face-attribute 'default nil :font
FONT is a string naming the font you want, for example,
"Droid Sans Mono-10".
This should work on all platforms. As of Emacs 23, all of your system fonts including TrueType are available to Emacs.
If you are using a development snapshot for what will become Emacs 24.4 then see Emacs bug #16529.
(There needs to be an explanation for how to set fonts for particular modes or buffers here. Including a set-face-attribute hook as described above for a particular mode does not work; once you enter that mode the new font is set, but it is applied globally to all other open buffers!)
I found that the only way to set fonts so that they remain consistent across emacs -nw, emacs23(-gtk), emacsclient -t, emacsclient -c, was to declare them in .Xresources and .emacs. But the declarations can’t conflict with each other. Otherwise, emacs --daemon complains. It doesn’t like (set-face-attribute ‘default nil :font FONT) and the like. For instance, to use Terminus, 9 pixel size across the board, I needed to insert
in my ~/.Xresources and ~/.emacs, respectively.
You can resize (text-scale) the text in a buffer (in all windows showing it), or you can resize the default font of a frame.
C-x C-+’ and
‘text-scale-adjust’) to increase or decrease the buffer text size (`
‘C--’to repeat). To restore the default (global) face height, type
‘S-mouse-1’pops up a menu where you can choose these same actions.
C-x C-+’ this does not scale the secondary font. For example, If you use a fontset –
NanumGothic_Codingfor hangul(Korean) – , increasing the text size does not scale the Korean characters. – cinsk
‘zoom-out’(in zoom-frm.el) – The first is a more general replacement for the vanilla command (
‘text-scale-adjust’) bound by default to `
‘C-x C-0’, and `
C-x C-=’. You can bind the other two to mouse-wheel rotations, so you can use the wheel like you do in a Web browser. You can also use these same commands to zoom a frame (see below):
‘C-u’for each command toggles between buffer and frame zooming. And
‘C-u’while repeating toggles buffer/frame on the fly during
‘doremi-buffer-font-size’(in doremi-frm.el) – Change buffer font size incrementally using the arrow keys or the mouse wheel.
You can use any of the following to increase or decrease the font size for the current frame, effectively resizing it incrementally – zooming the text in or out.
‘zoom-out’(in zoom-frm.el) – see above for the descriptions. For frame zooming these zoom all windows of the frame, and they do not affect the display in another frame of a buffer that is shown in the frame.
‘zoom-frm-unzoom’(in zoom-frm.el) – Undo any frame zooming from
‘toggle-zoom-frame’(in zoom-frm.el) – Alternately zoom a frame and unzoom it.
‘doremi-frame-font-size’(in doremi-frm.el) – Change frame font size incrementally using the arrow keys or the mouse wheel.
‘enlarge-font’(in frame-cmds.el) – Change font size by a given increment (prefix arg).
‘zoom-all-frames-out’(in zoom-frm.el) – Incrementally zoom all frames at once, by changing the size of face
You can change the size of a font for the current frame non-incrementally using
‘set-face-attribute’ with a
(set-face-attribute 'default (selected-frame) :height 100)
Alternatively, you can use
‘set-face-attribute’ with a
FONT string argument that has the size you want:
(set-frame-font "-outline-Courier New-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
(set-face-font 'default (selected-frame) "-outline-Courier New-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
(set-face-attribute 'default (selected-frame) :font "-outline-Courier New-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
If you are running Linux, you may be able to run `xfontsel` from a shell. This program helps you select a font. Once you’ve found one that you like, save the specification string. In my version, clicking the “select” button near the top left copies the string to my clipboard so I can yank (paste) it into Emacs.
Either set them in your InitFile:
(set-face-font 'menu "-jmk-neep alt-medium-r-*-*-20-*-*-*-c-*-iso8859-1") (set-face-font 'default "-jmk-neep alt-medium-r-*-*-20-*-*-*-c-*-iso8859-1")
Or set them in your ~/.Xresources or ~/.Xdefaults file (depending on your setup):
*.font: -jmk-neep alt-medium-r-*-*-20-*-*-*-c-*-iso8859-1 Emacs.pane.menubar.font: -jmk-neep alt-medium-r-*-*-20-*-*-*-c-*-iso8859-1
Actually, you may want to specify FontSets instead of a single font, if you are interested in displaying various fonts at the same time
Debian users: if your emacs startup fonts look ugly, that might be because you’ve installed the gsfonts-x11 package. gsfonts-x11 gives X the ability to display Ghostscript fonts, and they are poorly rendered on screen. To fix this, read the document that comes with gsfonts-x11, or Section 9.4.13 of the Debian Reference, "TrueType fonts in X".
As an emacs newbie, I feel this section quite incomplete. For most people, Installing a font means two things :
The section covers only the second point. I am quite willing to agree that emacs does thing differently for a bunch of reason, but please give me some light. (Even to tell it is some sort of X dependency, which I suspect but that doesn’t tell me what to do).
Note that arrived here after a search on “font” which, I think, seems quite a reasonable thing to do to install a new font. I didn’t see a newbie-specific page. – LionelB
For downloading fonts and installing them, there’s nothing Emacs-specific. Emacs uses your system’s fonts. If you’re using Emacs with X11, then use the X11 font installation technique (xset fp etc.). If you’re using Emacs with X11/Xft, then use the Xft font installation technique (.fonts.conf). If you’re using Emacs with MS Windows, then use the MS Windows font installation technique (Control Panel / Fonts). If you’re using Emacs with Mac, then use the Mac font installation technique (Font Book / Add Fonts).
Is it possible to test if a given font is available without an error or other side-effects? I just wrote:
(defun font-existsp (font) (if (string-equal (describe-font font) "No matching font being used") nil t))
but it has the side-effect of opening a description in Help if the font exists. I’m trying to set my init files to try a series of fonts and use the first available one. (I’m using Emacs 22.1.2 on OpenBSD?, fwiw.) -ScottVokes?
I figured out a simpler way: (defun font-existsp (font) (if (null (x-list-fonts font)) nil t))
I use this:
(member font-name (font-family-list))
Also I use this:
(find-font (font-spec :name font-name))
(require 'cl) (defun font-candidate (&rest fonts) "Return existing font which first match." (find-if (lambda (f) (find-font (font-spec :name f))) fonts))
;; Emacs23 style font setting. (set-face-attribute 'default nil :font (font-candidate '"Consolas-10:weight=normal" "DejaVu Sans Mono-10:weight=normal"))
Version using dash.el (call it the same way as above):
(require 'dash) (defun font-candidate (&rest fonts) "Return the first available font." (--first (find-font (font-spec :name it)) fonts))
Version using loop:
(require 'cl) (defun font-candidate (&rest fonts) (loop for font in fonts when (find-font (font-spec :name font)) return font))
I’d like to use TrueType Fonts in Emacs in various places, but Emacs handles them badly. Can someone tell me why TTF fonts are so much trouble in Emacs, and if there’s some way I could get emacs to play nicely with them anyway? --ShaeErisson
As of 23.3.1 TTF support is still quite defective (on Debian at least): for example, DejaVu? Sans Mono 11 is rendered at ~11.5pt, and 10pt is rendered at ~9.5pt. You’ll need to set a font size of e.g. 102-108 tenths to actually get 10pt text.
Customize the default face (
M-x customize-face RET default RET).
Alternatively, follow the following procedure:
M-x mac-font-panel-mode is not available on Emacs builds downloaded from http://emacsformacosx.com. On these builds, use the default Mac shortcut to popup the font panel, i.e, Command+T. Alternatively, use M-x ns-popup-font-panel. Then follow the instructions in the Carbon Emacs section.
From my personal experiences, there is no working-for-all-emacs solution for fontset. For current Emacs 24.x (from http://emacsformacosx.com/), below script can be one of the solution:
(when (eq system-type 'darwin) ;; default Latin font (e.g. Consolas) (set-face-attribute 'default nil :family "Consolas") ;; default font size (point * 10) ;; ;; WARNING! Depending on the default font, ;; if the size is not supported very well, the frame will be clipped ;; so that the beginning of the buffer may not be visible correctly. (set-face-attribute 'default nil :height 165) ;; use specific font for Korean charset. ;; if you want to use different font size for specific charset, ;; add :size POINT-SIZE in the font-spec. (set-fontset-font t 'hangul (font-spec :name "NanumGothicCoding")) ;; you may want to add different for other charset in this way. )