Skip to content

Instantly share code, notes, and snippets.

@MatthewDarling
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewDarling/8c232b1780126275c3b4 to your computer and use it in GitHub Desktop.
Save MatthewDarling/8c232b1780126275c3b4 to your computer and use it in GitHub Desktop.
Automatically change font-size based on resolution
;;; Based on http://arnab-deka.com/posts/2012/09/emacs-change-fonts-dynamically-based-on-screen-resolution/
(defun fontify-frame (&optional frame)
(interactive)
(let ((target (or frame (window-frame))))
(if window-system
(if (or
(> (frame-pixel-height) 2000)
(> (frame-pixel-width) 2000))
(set-frame-parameter target 'font "Menlo 19")
(set-frame-parameter target 'font "Menlo 16")))))
;;; Fontify current frame (so that it happens on startup; may be unnecessary if you use focus-in-hook)
(fontify-frame)
;;; Only in Emacs 24.4 (currently available as a pretest)
; see http://emacsredux.com/blog/2014/03/22/a-peek-at-emacs-24-dot-4-focus-hooks/
(add-hook 'focus-in-hook fontify-frame)
;;; For older Emacs versions - instead of changing on focus, this will change when a frame is created
;(push 'fontify-frame after-make-frame-functions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment