-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-fonts.el
39 lines (30 loc) · 1.33 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
(require 'cl)
(defun 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 increment-default-font-height (delta)
"Adjust the default font height by DELTA on every frame.
The pixel size of the frame is kept (approximately) the same.
DELTA should be a multiple of 10, in 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 (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 increase-default-font-height ()
(interactive)
(increment-default-font-height 10))
(defun decrease-default-font-height ()
(interactive)
(increment-default-font-height -10))
(global-set-key (kbd "C-M-=") 'increase-default-font-height)
(global-set-key (kbd "C-M--") 'decrease-default-font-height)
(provide 'init-fonts)