forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-fonts.el
40 lines (31 loc) · 1.43 KB
/
init-fonts.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(require 'cl)
(defun sanityinc/font-name-replace-size (font-name new-size)
(let ((parts (split-string font-name "-")))
(setcar (nthcdr 7 parts) (format "%d" new-size))
(mapconcat 'identity parts "-")))
(defun sanityinc/increment-default-font-height (delta)
"Adjust the default font height by DELTA on every frame.
Emacs will keep the pixel size of the frame approximately the
same. DELTA should be a multiple of 10, to match the units used
by the :height face attribute."
(let* ((new-height (+ (face-attribute 'default :height) delta))
(new-point-height (/ new-height 10)))
(dolist (f (frame-list))
(with-selected-frame f
;; Latest 'set-frame-font supports a "frames" arg, but
;; we cater to Emacs 23 by looping instead.
(set-frame-font (sanityinc/font-name-replace-size
(face-font 'default)
new-point-height)
t)))
(set-face-attribute 'default nil :height new-height)
(message "default font size is now %d" new-point-height)))
(defun sanityinc/increase-default-font-height ()
(interactive)
(sanityinc/increment-default-font-height 10))
(defun sanityinc/decrease-default-font-height ()
(interactive)
(sanityinc/increment-default-font-height -10))
(global-set-key (kbd "C-M-=") 'sanityinc/increase-default-font-height)
(global-set-key (kbd "C-M--") 'sanityinc/decrease-default-font-height)
(provide 'init-fonts)