Have mode icons detect if font is present

- Also add IcoMoon font
- Change the Unix encoding font to be:
  - IcoMoon Penguin or
  - Font Mfizz's Ubuntu or
  - Font Awesome Penguin

Depending on what fonts are installed
This commit is contained in:
Matthew L. Fidler 2016-02-26 10:56:35 -06:00
parent 3c289126bc
commit b9702ec376
2 changed files with 11 additions and 6 deletions

View file

@ -36,11 +36,10 @@ Some of the modes that have icons instead of names now:
- [[http://fontawesome.io/][Font Awesome]] - [[http://fontawesome.io/][Font Awesome]]
- [[https://octicons.github.com/][GitHub Octicons]] - [[https://octicons.github.com/][GitHub Octicons]]
- [[http://fizzed.com/oss/font-mfizz][Font Mfizz]] - [[http://fizzed.com/oss/font-mfizz][Font Mfizz]]
- [[https://icomoon.io/#icons-icomoon][IcoMoon]]
You need to have installed these on your system in order to use You need to have installed these on your system in order to use
these fonts, mode-icons will not do this for you. If you don't have these fonts, mode-icons will not do this for you.
them installed you may get some strange glyphs in your mode-line
instead.
* Installation * Installation

View file

@ -58,6 +58,7 @@
;; - Font Awesome, found at URL `http://fontawesome.io/'. ;; - Font Awesome, found at URL `http://fontawesome.io/'.
;; - GitHub Octicons, found at URL `https://octicons.github.com/'. ;; - GitHub Octicons, found at URL `https://octicons.github.com/'.
;; - Font Mfizz, found at URL `http://fizzed.com/oss/font-mfizz'. ;; - Font Mfizz, found at URL `http://fizzed.com/oss/font-mfizz'.
;; - IcoMoon, found at URL `https://icomoon.io/#icons-icomoon'.
;; ;;
;; You should have these installed if you want to use these icons, ;; You should have these installed if you want to use these icons,
;; otherwise you may get strange glyphs in your mode-line instead of ;; otherwise you may get strange glyphs in your mode-line instead of
@ -128,13 +129,14 @@ This was stole/modified from `c-save-buffer-state'"
"Define FONT for `mode-icons'." "Define FONT for `mode-icons'."
`(progn `(progn
(defvar ,(intern (format "mode-icons-font-spec-%s" font)) (defvar ,(intern (format "mode-icons-font-spec-%s" font))
(font-spec :name ,(format "%s" font))) (and (member ,(format "%s" font) (font-family-list)) (font-spec :name ,(format "%s" font))))
(defvar ,(intern (format "mode-icons-font-%s" font)) (defvar ,(intern (format "mode-icons-font-%s" font))
(find-font ,(intern (format "mode-icons-font-spec-%s" font)))))) (and (member ,(format "%s" font) (font-family-list)) (find-font ,(intern (format "mode-icons-font-spec-%s" font)))))))
(mode-icons-define-font "github-octicons") (mode-icons-define-font "github-octicons")
(mode-icons-define-font "font-mfizz") (mode-icons-define-font "font-mfizz")
(mode-icons-define-font "FontAwesome") (mode-icons-define-font "FontAwesome")
(mode-icons-define-font "IcoMoon-Free")
(defcustom mode-icons (defcustom mode-icons
`(("CSS" "css" xpm) `(("CSS" "css" xpm)
@ -209,7 +211,10 @@ This was stole/modified from `c-save-buffer-state'"
(apple #xf179 FontAwesome) (apple #xf179 FontAwesome)
(win #xf17a FontAwesome) (win #xf17a FontAwesome)
;; FIXME: use lsb_release to determine Linux variant and choose appropriate icon ;; FIXME: use lsb_release to determine Linux variant and choose appropriate icon
(unix #xeabd IcoMoon-Free) ;; Clear Tux (Unlike FontAwesome)
;; This icon is clearer than FontAwesome's Linux Penguin
(unix #xf166 font-mfizz) ;; Use ubuntu, since I think it is the most common. (unix #xf166 font-mfizz) ;; Use ubuntu, since I think it is the most common.
(unix #xf17c FontAwesome) ;; Fall Back to FontAwesome
(undecided #xf128 FontAwesome) (undecided #xf128 FontAwesome)
("Text\\'" #xf0f6 FontAwesome) ("Text\\'" #xf0f6 FontAwesome)
("\\` ?company\\'" #xf1ad FontAwesome) ("\\` ?company\\'" #xf1ad FontAwesome)
@ -240,6 +245,7 @@ without the extension. And the third being the type of icon."
(const :tag "Octicons" github-octicons) (const :tag "Octicons" github-octicons)
(const :tag "Fizzed" font-mfizz) (const :tag "Fizzed" font-mfizz)
(const :tag "Font Awesome" FontAwesome) (const :tag "Font Awesome" FontAwesome)
(const :tag "Ico Moon Free" IcoMoon-Free)
(const :tag "png" png) (const :tag "png" png)
(const :tag "gif" gif) (const :tag "gif" gif)
(const :tag "jpeg" jpeg) (const :tag "jpeg" jpeg)