-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nerd font support #220
Comments
nerd font is nice, but it doesn't have a emacs logo, so this probably won't happen until they have one |
Wow what a travesty? 😞 Is this the only hang-up though? You mention in #143 that combining together will be hard because the same code-points are used by different fonts. This makes life a lot harder for terminal users like me because icons are reliant on the order in which fonts are configured and in my case a-lot of the buffer-mode-icons are incorrect, but fixing that makes the emacs and org-mode icons incorrect 😢. S.N. Links to relevent issues nerd-fonts/#342, #143. |
I've managed to override a lot of the all-the-icon fonts with nerd-font like so: (defvar +icons-prefer-nerd-font t)
(use-package nerd-fonts
:straight (nerd-fonts :type git :host github :repo "twlz0ne/nerd-fonts.el")
:after all-the-icons
:demand t
:config
(require 'nerd-fonts-data)
(defvar nerd-fonts-families+
(eval-when-compile
(seq-uniq
(cl-loop with pos = nil
for (icon . _) in nerd-fonts-alist
do (setq pos (cl-loop with count = 0
for char across icon
when (eq char ?-)
return count
else
do (setq count (1+ count))))
collect (substring icon 0 pos)))))
(defmacro all-the-icons-nerd-font-family+ (family)
(let* ((nerd-family (concat "nerd-" family))
(font-alist (intern (concat "all-the-icons-data/" nerd-family "-alist")))
(name (intern nerd-family)))
`(progn
(defvar ,font-alist
(eval-when-compile
(cl-loop for (name . icon) in nerd-fonts-alist
when (string-prefix-p ,family name)
collect (cons (substring name ,(1+ (length family)))
icon))))
(all-the-icons-define-icon ,name ,font-alist ,nerd-family
;; The font on my linux machine, maybe needs updating depending on platform
"Symbols-2048-em Nerd Font Complete.ttf"))))
(dolist (it nerd-fonts-families+)
(eval
`(all-the-icons-nerd-font-family+ ,it)))
;; Replace any none nerd-font lookups with nerd-font lookups.
(when +icons-prefer-nerd-font
(let ((subs (eval-when-compile
(cl-loop for (family . ati-var) in '(("fa" . all-the-icons-faicon)
("mdi" . all-the-icons-material)
("oct" . all-the-icons-octicon)
("weather" . all-the-icons-wicon))
when (member family nerd-fonts-families+)
collect (cons ati-var
(intern (concat "all-the-icons-nerd-" family)))))))
;; When we have a key-value mapping setup in subs
(when subs
;; For each variable all-the-icons uses to lookup contextual icons.
(dolist (var '(all-the-icons-icon-alist
all-the-icons-dir-icon-alist
all-the-icons-weather-icon-alist
all-the-icons-mode-icon-alist
all-the-icons-url-alist))
;; For each entry in those lists do key-value substitution with `subs'.
(dolist (assoc (symbol-value var))
(when-let ((new-icon-func (alist-get (nth 1 assoc) subs)))
(setcar (cdr assoc) new-icon-func)))))))) This defines a bunch of all-the-icon font families with nerd- prefixes (eg. Sadly the alltheicon and fileicon families don't seem to have nerd-font equivalents (at least none that can be found in the nerd-font package). These you'll have to setup manually :( EDIT: I've ended up using a fork of the nerd-fonts package because there're issues with the default version and this setup. See nerd-fonts#2. |
Really want icons in the terminal. Neovim's working well with Nerd Font. |
using a nerd font as emacs font face breaks all-the-icons functionality (renders wrong icon).
Considering the usage and font contents seem to be 90% the same and nerd font is a cross platform project. is it possible to get support for nerd fonts into all the icons?
The text was updated successfully, but these errors were encountered: