Fix cycle-font

This commit is contained in:
Henrik Lissner 2015-01-21 00:42:09 -05:00
parent bf9ef826c5
commit 4e32b006b1
3 changed files with 14 additions and 15 deletions

View file

@ -2,18 +2,9 @@
;;;; Load Theme ;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Load Theme ;;;;;;;;;;;;;;;;;;;;;;;;
(when window-system (when window-system
;; No transparency!
(set-frame-parameter nil 'alpha '(94 70)) (set-frame-parameter nil 'alpha '(94 70))
(let* ((font (nth 0 *fonts)) ;; Load font
(font-name (nth 0 font)) (cycle-font 0))
(font-size (nth 1 font))
(font-aa (nth 2 font)))
(unless (member font-name (font-family-list))
(error "Font %s isn't installed" font-name))
(let ((font-str (concat font-name "-" (number-to-string font-size))))
(setq ns-antialias-text font-aa)
(add-to-list 'default-frame-alist `(font . ,font-str))
(add-to-list 'initial-frame-alist `(font . ,font-str)))))
(add-to-list 'custom-theme-load-path my-themes-dir) (add-to-list 'custom-theme-load-path my-themes-dir)
(load-dark-theme) (load-dark-theme)

View file

@ -39,15 +39,22 @@
(load-dark-theme))) (load-dark-theme)))
;;;###autoload ;;;###autoload
(defun cycle-font () (defun cycle-font (&optional i)
"Cycle between fonts specified in *fonts in init.el" "Cycle between fonts specified in *fonts in init.el"
(interactive) (interactive)
(if (>= my/cycle-font-i (1- (length *fonts))) (if (numberp i)
(setq my/cycle-font-i 0) (setq my/cycle-font-i i)
(cl-incf my/cycle-font-i)) (if (>= my/cycle-font-i (1- (length *fonts)))
(setq my/cycle-font-i 0)
(cl-incf my/cycle-font-i)))
(let* ((font (nth my/cycle-font-i *fonts)) (let* ((font (nth my/cycle-font-i *fonts))
(font-name (nth 0 font)) (font-name (nth 0 font))
(font-size (nth 1 font)) (font-size (nth 1 font))
(font-aa (nth 2 font))) (font-aa (nth 2 font)))
(unless (member font-name (font-family-list))
(error "Font %s isn't installed" font-name))
(let ((font-str (concat font-name "-" (number-to-string font-size))))
(add-to-list 'default-frame-alist `(font . ,font-str))
(add-to-list 'initial-frame-alist `(font . ,font-str)))
(load-font font-name font-size) (load-font font-name font-size)
(setq ns-antialias-text font-aa))) (setq ns-antialias-text font-aa)))

View file

@ -31,6 +31,7 @@
(defconst *light-theme 'github) ; wtb better light theme... (defconst *light-theme 'github) ; wtb better light theme...
(defconst *fonts `(("Terminus (TTF)" ,(if (eq system-name "ganymede.local") 9 12) nil) (defconst *fonts `(("Terminus (TTF)" ,(if (eq system-name "ganymede.local") 9 12) nil)
("Ubuntu Mono" 16 t)
("Inconsolata" 22 t))) ("Inconsolata" 22 t)))
(add-to-list 'load-path my-core-dir) (add-to-list 'load-path my-core-dir)