Reputation: 11461
I am using Emacs 23.3. How can I change the font size and font type?
Upvotes: 104
Views: 122521
Reputation: 173
Using customize to set font size happens too late and the first
emacs frame "flashes" (and may resize over the edge of a screen),
therefore, with emacs 29.4 I've added the following in
~/.emacs.d/early-init.el
:
(when initial-window-system ;; i-w-s from stack exchange
(add-to-list 'default-frame-alist '(font . "EmblCondHack-13")))
s/EmblCondHack/Monospace/
should work for everyone
Upvotes: 1
Reputation: 6950
Get current font by:
M-x describe-font
(Hit Enter
if you see Font name (default current choice for ASCII chars):
)
This will show a list of attributes which can be set in init.el
. After you've had a look the values, minimize the message buffer by C-x 1
.
Now do a M-x customize-face
and:
Enter
on "State" and then 1 = Save for Future SessionsAlternatively, in init.el
you could have something like:
(set-face-attribute 'default nil :font "Monospace" :height 160)
Note: If you have a preset for window size (width and height), the height
attribute of the font is going to interfere with that layout.
Upvotes: 15
Reputation: 1210
Simply press M-x
, and then type in set-frame-font
. All available fonts which exist in your machine will be displayed.
Choose the one you look for. I use this way to change font-type in my Emacs so simply; rather than altering the .spacemacs
or .emacs
file.
Upvotes: 2
Reputation: 3301
Emacs 25.1 on macOS has Menlo 12 as default. I wanted to increase the size.
C-x C-f
~/.emacs
Add this to end of the ~/.emacs
file:
(set-default-font "Menlo 14")
To see the change take effect immediately while staying in ~/.emacs
:
M-x eval-buffer [RET]
Upvotes: 4
Reputation: 8387
The Emacs way
customize-group
faces
Upvotes: 3
Reputation: 5052
In my answer, I'll concentrate on setting the default font size through X resources. The use of X resources has already been mentioned in the answer mentioning ~/.Xdefaults
; I'll give more details (the same which I have already described in https://unix.stackexchange.com/a/426914/4319. Apart from the height of the "default" "face" in Emacs, one can similarly set other font parameters.
To set a specific default font height for Emacs, I have put into /etc/X11/Xresources-site
(/etc/X11/Xresources
is also OK, though can be overwritten by your distro):
Emacs.default.attributeHeight: 94
This would affect also remote X clients which are Emacs (e.g., emacs started on a remote host via ssh).
/etc/X11/Xresources-site
and /etc/X11/Xresources
(and probably ~/.Xresources
and ~/.Xdefaults
) are usually read at the start of your X session; to affect your current X resources immediately, run something like xrdb -merge /etc/X11/Xresources-site
. The X resources can be viewed by xrdb -query
.
Actually, in my case, /etc/X11/Xresources-site
is being read thanks to a line in /etc/X11/Xresources
(which is read by the start scripts):
#include "/etc/X11/Xresources-site"
so /etc/X11/Xresources
is the thing that is read for sure.
There are also some files with the same syntax which are read each time an X program like emacs starts. In my case, they are: ~/.Xdefaults-MY_HOST_NAME
, /etc/X11/app-defaults/Emacs
(only for emacs-athena, not for emacs-gtk3), /usr/share/X11/app-defaults/Emacs
etc. (But I like the idea of loaded X resources more -- shown with xrdb -query
; so that remote X clients read the same X resources.)
Other X resources which Emacs understands are described at https://www.gnu.org/software/emacs/manual/html_node/emacs/Table-of-Resources.html#Table-of-Resources.
Emacs 24.3 had a bug which made it not honor the attributes for the default face coming from the X resources, such as in my example above. This was fixed since 24.4.
Upvotes: 4
Reputation: 4983
You can also do the following in your .emacs
file.
(set-frame-font "Inconsolata 12" nil t)
(set-default-font "Inconsolata 12" nil t)
Upvotes: 150
Reputation: 10274
If you use Linux/X11, you may need to set this in ~/.Xdefaults
. I
have set the font there since the other answers here have no effect.
I'm able to see available font settings by running in Emacs:
helm-select-xfont
Then I start typing Conso
and I see entries like:
-Consolas-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1
...
So then I put it into ~/.Xdefaults
, setting size 12
as:
Emacs.font: xft:-*-Consolas-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1
and restart Emacs.
Upvotes: 2
Reputation: 68172
You can use the menu bar. Go to Options
->Set Default Font...
.
After you choose a font, don't forget to press Options
->Save Options
—otherwise your new font will not be saved after you close Emacs.
Upvotes: 100