summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-04-27 13:22:08 +0100
committerAlan Pearce2014-04-27 13:22:08 +0100
commit0da5abaf2490fc2d77750393a0ada37811d21636 (patch)
treec726a54f44955b0a7535153136496fb781f624e5 /tag-emacs
parentb712ec045dd12d913ea08d4be08a31b3d162c4e3 (diff)
downloaddotfiles-0da5abaf2490fc2d77750393a0ada37811d21636.tar.lz
dotfiles-0da5abaf2490fc2d77750393a0ada37811d21636.tar.zst
dotfiles-0da5abaf2490fc2d77750393a0ada37811d21636.zip
Emacs: Refactor and simplify font settings
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.el37
1 files changed, 11 insertions, 26 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index 7ee336d..1eed32e 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -86,35 +86,20 @@
     (variable-pitch-mode)
     (setq cursor-type 'bar))
 
+  (defun ap/set-fonts (mono-face variable-face font-size)
+    (when mono-face
+      (let ((default-font (concat mono-face "-" (number-to-string font-size))))
+        (add-to-list 'default-frame-alist `(font . ,default-font))
+        (set-face-font 'fixed-pitch default-font)))
+    (when variable-face
+      (set-face-font 'variable-pitch (concat variable-face "-"
+                                             (number-to-string (1+ font-size))))))
+
   (cond
    ((eq window-system 'w32)
-    (let* ((font-size 10)
-           (font-list (font-family-list))
-           (mono-face (cond
-                       ((member "Liberation Mono" font-list)
-                        "Liberation Mono")
-                       ((member "Liberation Sans Mono" font-list)
-                        "Liberation Sans Mono")
-                       ((member "Consolas" font-list)
-                        "Consolas")))
-           (variable-face "Segoe UI")
-           (default-font (concat mono-face "-" (number-to-string font-size))))
-        (when mono-face
-          (add-to-list 'default-frame-alist `(font . ,default-font))
-          (set-face-font 'fixed-pitch default-font))
-        (when variable-face
-          (set-face-font 'variable-pitch (concat variable-face "-"
-                                                   (number-to-string (1+ font-size)))))))
+    (ap/set-fonts "Consolas" "Segoe UI" 10))
    ((eq system-type 'darwin)
-    (let* ((font-size 14)
-           (mono-face "Droid Sans Mono")
-           (variable-face "Helvetica_Neue")
-           (default-font (concat mono-face "-" (number-to-string font-size))))
-        (when mono-face
-          (add-to-list 'default-frame-alist `(font . ,default-font)))
-        (when (and variable-face (display-graphic-p))
-          (set-face-font 'variable-pitch (concat variable-face "-"
-                                                 (number-to-string (1+ font-size)))))))))
+    (ap/set-fonts "Droid Sans Mono" "Helvetica_Neue" 14))))
 
 (let* ((font-height (face-attribute 'default :height))
        (small-font-height (max 1 (floor (* .917 font-height)))))