Skip to content

Instantly share code, notes, and snippets.

@jclosure
Created July 14, 2021 03:57
Show Gist options
  • Save jclosure/8cf9ba2de9386d75aa2c27a6315bf915 to your computer and use it in GitHub Desktop.
Save jclosure/8cf9ba2de9386d75aa2c27a6315bf915 to your computer and use it in GitHub Desktop.
Emacs set font-size based on monitor size.
;; set some defaults
(setq my-font-name "monospace")
(setq my-font-size 10)
;; this method seems to work on gui systems only
(when window-system
(if (eq system-type 'darwin)
(setq my-font-name "Meslo"))
(if (eq system-type 'gnu/linux)
(setq my-font-name "FiraCode"))
(if (> (x-display-pixel-width) 1600)
(setq my-font-size 16))
(if (<= (x-display-pixel-width) 1600)
(setq my-font-size 11)))
;; set the font
(set-frame-font (format "%s %d" my-font-name my-font-size))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment