Emacs: Change Default Font Size by Command, for Current Session 🚀

By Xah Lee. Date: .

This command set a default font size across all buffers and windows, for the current session only.

put this in your Emacs Init File:

(defun xah-set-default-font-size ()
  "Set default font globally.
Note, this command change font size only for current session, not in init file.
This command useful for making font large when you want to do video livestream.
URL `http://xahlee.info/emacs/emacs/emacs_set_default_font_size.html'
Version: 2021-07-26 2021-08-21 2022-08-05"
  (let (($fSize (read-string "size:" "16" nil "16")))
    (if (> (string-to-number $fSize) 51)
        (user-error "Max font size allowed is 51. You gave %s " $fSize)
        ((string-equal system-type "windows-nt")
         (if (member "Consolas" (font-family-list)) (format "Consolas-%s" $fSize) nil))
        ((string-equal system-type "darwin")
         (if (member "Menlo" (font-family-list)) (format "Menlo-%s" $fSize) nil))
        ((string-equal system-type "gnu/linux")
         (if (member "DejaVu Sans Mono" (font-family-list)) "DejaVu Sans Mono" nil))
        (t nil))
       t t))))