How to set the font size in Emacs?

前端 未结 17 1537
囚心锁ツ
囚心锁ツ 2020-11-28 17:43

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

相关标签:
17条回答
  • 2020-11-28 18:03

    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))))))
    
    0 讨论(0)
  • 2020-11-28 18:05

    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)
    
    0 讨论(0)
  • 2020-11-28 18:06

    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.

    0 讨论(0)
  • 2020-11-28 18:07

    Press Shift and the first mouse button. You can change the font size in the following way: This website has more detail.

    0 讨论(0)
  • 2020-11-28 18:08

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

    0 讨论(0)
提交回复
热议问题