0

I want to be able to switch between "Consolas-12" and "Georgia-13" using key bindings. Can I do that? How?

3

Are you looking to set the default font as you might with the "Options -> Set default font..." menu item?

The relevant command is set-frame-font. You can write a command to toggle between two (or more) fonts like this:

(defcustom my-default-fonts
  '("Consolas-12" "Georgia-13") "List of default fonts")

(defun toggle-frame-font ()
  "Toggle between default fonts."
  (interactive)
  (add-to-list 'my-default-fonts (pop my-default-fonts) t) ; rotate list
  (set-frame-font (car my-default-fonts) nil t))

Then bind it to key, for example:

(global-set-key (kbd "<f11>") #'toggle-frame-font)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.