From 0da5abaf2490fc2d77750393a0ada37811d21636 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 27 Apr 2014 13:22:08 +0100 Subject: Emacs: Refactor and simplify font settings --- tag-emacs/emacs.d/init.el | 37 +++++++++++-------------------------- 1 file 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))))) -- cgit 1.4.1