mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-22 01:50:28 +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.
|
- Helm minor mode icon.
|
||||||
- Javascript-IDE mode (js2-mode) icon.
|
- Javascript-IDE mode (js2-mode) icon.
|
||||||
- Auto indent minor mode (from Font Awesome)
|
- Auto indent minor mode (from Font Awesome)
|
||||||
|
- Automatic setup of arbitrary font, currently still support
|
||||||
|
IcoMoon-Free, FontAwesome, font-mfizz and github-octicons.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -134,19 +134,6 @@ This was stole/modified from `c-save-buffer-state'"
|
||||||
(buffer-modified-p)
|
(buffer-modified-p)
|
||||||
(set-buffer-modified-p nil)))))
|
(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
|
(defcustom mode-icons
|
||||||
`(("\\`CSS\\'" "css" xpm)
|
`(("\\`CSS\\'" "css" xpm)
|
||||||
("\\`Coffee\\'" "coffee" xpm-bw)
|
("\\`Coffee\\'" "coffee" xpm-bw)
|
||||||
|
@ -270,13 +257,9 @@ without the extension. And the third being the type of icon."
|
||||||
(choice
|
(choice
|
||||||
(string :tag "Icon Name")
|
(string :tag "Icon Name")
|
||||||
(integer :tag "Font Glyph Code")
|
(integer :tag "Font Glyph Code")
|
||||||
(const :tag "Suppress" nil))
|
(const :tag "ess" nil))
|
||||||
(choice
|
(choice
|
||||||
(const :tag "text" nil)
|
(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 "png" png)
|
||||||
(const :tag "gif" gif)
|
(const :tag "gif" gif)
|
||||||
(const :tag "jpeg" jpeg)
|
(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 "xpm" xpm)
|
||||||
(const :tag "Black and White xpm that changes color to match the mode-line face" xpm-bw)
|
(const :tag "Black and White xpm that changes color to match the mode-line face" xpm-bw)
|
||||||
(const :tag "Emoji" emoji)
|
(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)
|
:group 'mode-icons)
|
||||||
|
|
||||||
(defvar mode-icons-get-xpm-string (make-hash-table :test 'equal))
|
(defvar mode-icons-get-xpm-string (make-hash-table :test 'equal))
|
||||||
|
@ -631,22 +615,27 @@ Use EVENT to determine location."
|
||||||
When DONT-REGISTER is non-nil, don't register the font.
|
When DONT-REGISTER is non-nil, don't register the font.
|
||||||
Otherwise, register the font for use in the mode-line and
|
Otherwise, register the font for use in the mode-line and
|
||||||
everywhere else."
|
everywhere else."
|
||||||
(when (and (or (integerp char)
|
(if (memq font '(ext emoji xpm xbm jpg jpeg gif png nil)) nil
|
||||||
(and (stringp char) (= 1 (length char))))
|
(unless (boundp (intern (format "mode-icons-font-spec-%s" font)))
|
||||||
(boundp (intern (format "mode-icons-font-spec-%s" font)))
|
(set (intern (format "mode-icons-font-spec-%s" font))
|
||||||
(symbol-value (intern (format "mode-icons-font-spec-%s" font))))
|
(and (member (format "%s" font) (font-family-list))
|
||||||
(let* ((char (or (and (integerp char) char)
|
(font-spec :name (format "%s" font)))))
|
||||||
(and (stringp char) (= 1 (length char))
|
(when (and (or (integerp char)
|
||||||
(aref (vconcat char) 0))))
|
(and (stringp char) (= 1 (length char))))
|
||||||
(found-char-p (assoc char mode-icons-font-register-alist))
|
(boundp (intern (format "mode-icons-font-spec-%s" font)))
|
||||||
(char-font-p (and found-char-p (eq (cdr found-char-p) font))))
|
(symbol-value (intern (format "mode-icons-font-spec-%s" font))))
|
||||||
(cond
|
(let* ((char (or (and (integerp char) char)
|
||||||
(char-font-p t)
|
(and (stringp char) (= 1 (length char))
|
||||||
(found-char-p t)
|
(aref (vconcat char) 0))))
|
||||||
(t ;; not yet registered.
|
(found-char-p (assoc char mode-icons-font-register-alist))
|
||||||
(set-fontset-font t (cons char char) (symbol-value (intern (format "mode-icons-font-spec-%s" font))))
|
(char-font-p (and found-char-p (eq (cdr found-char-p) font))))
|
||||||
(push (cons char font) mode-icons-font-register-alist)
|
(cond
|
||||||
t)))))
|
(char-font-p t)
|
||||||
|
(found-char-p t)
|
||||||
|
(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))))))
|
||||||
|
|
||||||
(defun mode-icons-supported-p (icon-spec)
|
(defun mode-icons-supported-p (icon-spec)
|
||||||
"Determine if ICON-SPEC is suppored on your system."
|
"Determine if ICON-SPEC is suppored on your system."
|
||||||
|
|
Loading…
Reference in a new issue