Last active
August 29, 2015 14:02
-
-
Save MatthewDarling/8c232b1780126275c3b4 to your computer and use it in GitHub Desktop.
Automatically change font-size based on resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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