Browse Source

Updated logic for font loading and fallback

master
Josh Wolfe 3 years ago
parent
commit
0570ec90f2
1 changed files with 20 additions and 4 deletions
  1. 20
    4
      emacs/.emacs.d/README.org

+ 20
- 4
emacs/.emacs.d/README.org View File

@@ -221,12 +221,27 @@ I don't really want to have to look at menu bars that I'm not going to use

*** Fonts

I like Inconsolata so use it if installed.
Quick macro that tries to load the font. If it loads it return =t= so we
know not to try and load anything else if it returns =nil= then we'll
try a different font.

#+BEGIN_SRC emacs-lisp :tangle yes
(when (member "Inconsolata" (font-family-list)) ; Set default font
(add-to-list 'default-frame-alist '(font . "Inconsolata-15" ))
(set-face-attribute 'default t :font "Inconsolata-15"))
(defmacro load-font-if-exists (family size)
(if (member family (font-family-list)) ; Set default font
(progn
(let ((font-and-size (format "%s-%s" family size)))
(add-to-list 'default-frame-alist `(font . ,font-and-size))
(set-face-attribute 'default t :font font-and-size))
t)
nil))
#+END_SRC

I like =Inconsolata-dz= a bit more than =Inconsolata= so use it if installed
otherwise fall back to regular =Inconsolata=.

#+BEGIN_SRC emacs-lisp :tangle yes
(unless (load-font-if-exists "Inconsolata-dz" 15)
(load-font-if-exists "Inconsolata" 15))
#+END_SRC

Make sure that UTF-8 is used everywhere.
@@ -1438,3 +1453,4 @@ Stores all backups and temp files in =~/.bak.emacs/=
(reverse comments)))
#+END_SRC



Loading…
Cancel
Save