How to set the font size in Emacs?

2020-01-24 18:33发布

I also want to save the font size in my .emacs file.

17条回答
欢心
2楼-- · 2020-01-24 19:01

From Emacswiki, GNU Emacs 23 has a built-in key combination:

C-xC-+ and C-xC-- to increase or decrease the buffer text size

查看更多
地球回转人心会变
3楼-- · 2020-01-24 19:03
(set-face-attribute 'default nil :height 100)

The value is in 1/10pt, so 100 will give you 10pt, etc.

查看更多
一夜七次
4楼-- · 2020-01-24 19:07

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)
查看更多
Deceive 欺骗
5楼-- · 2020-01-24 19:09

In NTEmacs 23.1, the Options menu has a "Set default font..." option.

查看更多
该账号已被封号
6楼-- · 2020-01-24 19:10

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.

查看更多
Luminary・发光体
7楼-- · 2020-01-24 19:13

In AquaMacs CMD + and CMD - adjust the font size for the current buffer.

查看更多
登录 后发表回答