mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-21 17:40:30 +01:00
Add automatic font setup
This commit is contained in:
parent
f73550e9bf
commit
eaf93f52d3
2 changed files with 26 additions and 35 deletions
|
@ -24,6 +24,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||
- Helm minor mode icon.
|
||||
- Javascript-IDE mode (js2-mode) icon.
|
||||
- Auto indent minor mode (from Font Awesome)
|
||||
- Automatic setup of arbitrary font, currently still support
|
||||
IcoMoon-Free, FontAwesome, font-mfizz and github-octicons.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -134,19 +134,6 @@ This was stole/modified from `c-save-buffer-state'"
|
|||
(buffer-modified-p)
|
||||
(set-buffer-modified-p nil)))))
|
||||
|
||||
(defmacro mode-icons-define-font (font)
|
||||
"Define FONT for `mode-icons'."
|
||||
`(progn
|
||||
(defvar ,(intern (format "mode-icons-font-spec-%s" font))
|
||||
(and (member ,(format "%s" font) (font-family-list)) (font-spec :name ,(format "%s" font))))
|
||||
(defvar ,(intern (format "mode-icons-font-%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 "font-mfizz")
|
||||
(mode-icons-define-font "FontAwesome")
|
||||
(mode-icons-define-font "IcoMoon-Free")
|
||||
|
||||
(defcustom mode-icons
|
||||
`(("\\`CSS\\'" "css" xpm)
|
||||
("\\`Coffee\\'" "coffee" xpm-bw)
|
||||
|
@ -270,13 +257,9 @@ without the extension. And the third being the type of icon."
|
|||
(choice
|
||||
(string :tag "Icon Name")
|
||||
(integer :tag "Font Glyph Code")
|
||||
(const :tag "Suppress" nil))
|
||||
(const :tag "ess" nil))
|
||||
(choice
|
||||
(const :tag "text" nil)
|
||||
(const :tag "Octicons" github-octicons)
|
||||
(const :tag "Fizzed" font-mfizz)
|
||||
(const :tag "Font Awesome" FontAwesome)
|
||||
(const :tag "Ico Moon Free" IcoMoon-Free)
|
||||
(const :tag "png" png)
|
||||
(const :tag "gif" gif)
|
||||
(const :tag "jpeg" jpeg)
|
||||
|
@ -285,7 +268,8 @@ without the extension. And the third being the type of icon."
|
|||
(const :tag "xpm" xpm)
|
||||
(const :tag "Black and White xpm that changes color to match the mode-line face" xpm-bw)
|
||||
(const :tag "Emoji" emoji)
|
||||
(const :tag "Mode Icons Generated file-type" ext))))
|
||||
(const :tag "Mode Icons Generated file-type" ext)
|
||||
(symbol :tag "Font"))))
|
||||
:group 'mode-icons)
|
||||
|
||||
(defvar mode-icons-get-xpm-string (make-hash-table :test 'equal))
|
||||
|
@ -631,6 +615,11 @@ Use EVENT to determine location."
|
|||
When DONT-REGISTER is non-nil, don't register the font.
|
||||
Otherwise, register the font for use in the mode-line and
|
||||
everywhere else."
|
||||
(if (memq font '(ext emoji xpm xbm jpg jpeg gif png nil)) nil
|
||||
(unless (boundp (intern (format "mode-icons-font-spec-%s" font)))
|
||||
(set (intern (format "mode-icons-font-spec-%s" font))
|
||||
(and (member (format "%s" font) (font-family-list))
|
||||
(font-spec :name (format "%s" font)))))
|
||||
(when (and (or (integerp char)
|
||||
(and (stringp char) (= 1 (length char))))
|
||||
(boundp (intern (format "mode-icons-font-spec-%s" font)))
|
||||
|
@ -646,7 +635,7 @@ everywhere else."
|
|||
(t ;; not yet registered.
|
||||
(set-fontset-font t (cons char char) (symbol-value (intern (format "mode-icons-font-spec-%s" font))))
|
||||
(push (cons char font) mode-icons-font-register-alist)
|
||||
t)))))
|
||||
t))))))
|
||||
|
||||
(defun mode-icons-supported-p (icon-spec)
|
||||
"Determine if ICON-SPEC is suppored on your system."
|
||||
|
|
Loading…
Reference in a new issue