I also want to save the font size in my .emacs
file.
Here's a snippet that lets you directly specify the global font size using an interactive function:
(defun set-font-size ()
"Set the font size."
(interactive)
(set-face-attribute
'default nil :height
(string-to-number
(read-string "Font size: " (number-to-string (face-attribute 'default :height nil))))))
I use hydra package to control font increase/decrease contiguously by pressing f2 + + + +
/f2 - - - -
, which means that press f2
once, and then using +
/-
to control only, and restore default font size by f2 0
. Because i have keypad, so I also bind keypad to the font setting.
(defhydra hydra-zoom (global-map "<f2>")
"zoom"
("<kp-add>" text-scale-increase "in")
("+" text-scale-increase "in")
("-" text-scale-decrease "out")
("<kp-subtract>" text-scale-decrease "out")
("0" (text-scale-set 0) "reset")
("<kp-0>" (text-scale-set 0) "reset"))
And modern editor mouse control functionality supported by below key bindings, press control + mouse wheel to increase/decrease font.
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
Aquamacs:
(set-face-attribute 'default nil :font "Monaco-16" )
From the Emacs Wiki Globally Change the Default Font, it says you can use either of these:
(set-face-attribute 'default nil :font FONT )
(set-frame-font FONT nil t)
Where FONT
is something like "Monaco-16"
, e.g.:
(set-face-attribute 'default nil :font "Monaco-16" )
There was an extra closing parenthesis in the first suggestion on the wiki, which caused an error on startup. I finally noticed the extra closing parenthesis, and I subsequently corrected the suggestion on the wiki. Then both of the suggestions worked for me.
Press Shift and the first mouse button. You can change the font size in the following way: This website has more detail.
In NTEmacs 23.1, the Options menu has a "Set default font..." option.