mohkale / all-the-icons-nerd-fonts

Nerd font integration for all-the-icons
GNU General Public License v3.0
36 stars 2 forks source link

Not so much an issue as an idea. #1

Open Mihara opened 2 years ago

Mihara commented 2 years ago

With Emacs in particular (and with kitty where I picked up the technique) you don't have to use the patched nerd fonts: you can override part of the fontset with another font that only contains the icon glyphs.

This way, you could potentially avoid installing the fonts from all-the-icons altogether and avoid using patched fonts. This appears to work well with all-the-icons-nerd-fonts as it is now.

This is how I do it:

  1. Install https://github.com/ryanoasis/nerd-fonts/blob/master/src/glyphs/Symbols-2048-em%20Nerd%20Font%20Complete.ttf
  2. Do magic with set-fontset-font:
    
    (defun mihara/attach-nerd-font (&rest maybe-a-frame)
    "Attach the Symbols Nerd Font with `set-fontset-font'.
    Parameter MAYBE-A-FRAME is actually ignored."
    ;; It's only needed so that this function runs in newly created frames,
    ;; which is needed with a daemon Emacs process starting a new frame
    ;; when no others are open.
    (interactive) ;; To make it easier to fix manually in case of issues.
    (dolist (target
           '((#X23fb . #X23fe)
             #X2665
             #X26a1
             #X2b58
             (#Xe000 . #Xe00a)
             (#Xe0a0 . #Xe0a3)
             (#Xe0b0 . #Xe0c8)
             #Xe0ca
             (#Xe0cc . #Xe0d2)
             #Xe0d4
             (#Xe200 . #Xe2a9)
             (#Xe300 . #Xe3e3)
             (#Xe5fa . #Xe62f)
             (#Xe700 . #Xe7c5)
             (#Xf000 . #Xf00e)
             (#Xf010 . #Xf01e)
             (#Xf021 . #Xf03e)
             (#Xf040 . #Xf04e)
             (#Xf050 . #Xf05e)
             (#Xf060 . #Xf06e)
             (#Xf070 . #Xf07e)
             (#Xf080 . #Xf08e)
             (#Xf090 . #Xf09e)
             (#Xf0a0 . #Xf0ae)
             (#Xf0b0 . #Xf0b2)
             (#Xf0c0 . #Xf0ce)
             (#Xf0d0 . #Xf0de)
             (#Xf0e0 . #Xf0ee)
             (#Xf0f0 . #Xf0fe)
             (#Xf100 . #Xf10e)
             (#Xf110 . #Xf11e)
             (#Xf120 . #Xf12e)
             (#Xf130 . #Xf13e)
             (#Xf140 . #Xf14e)
             (#Xf150 . #Xf15e)
             (#Xf160 . #Xf16e)
             (#Xf170 . #Xf17e)
             (#Xf180 . #Xf18e)
             (#Xf190 . #Xf19e)
             (#Xf1a0 . #Xf1ae)
             (#Xf1b0 . #Xf1be)
             (#Xf1c0 . #Xf1ce)
             (#Xf1d0 . #Xf1de)
             (#Xf1e0 . #Xf1ee)
             (#Xf1f0 . #Xf1fe)
             (#Xf200 . #Xf20e)
             (#Xf210 . #Xf21e)
             (#Xf221 . #Xf23e)
             (#Xf240 . #Xf24e)
             (#Xf250 . #Xf25e)
             (#Xf260 . #Xf26e)
             (#Xf270 . #Xf27e)
             (#Xf280 . #Xf28e)
             (#Xf290 . #Xf29e)
             (#Xf2a0 . #Xf2ae)
             (#Xf2b0 . #Xf2be)
             (#Xf2c0 . #Xf2ce)
             (#Xf2d0 . #Xf2de)
             #Xf2e0
             (#Xf300 . #Xf31c)
             (#Xf400 . #Xf4a9)))
    (set-fontset-font nil target "Symbols Nerd Font")))

;; This is the list according to Kitty-term documentation. ;; ((#X23fb . #X23fe) #X2b58 (#Xe200 . #Xe2a9) (#Xe0a0 . #Xe0a3) ;; (#Xe0b0 . #Xe0bf) (#Xe0c0 . #Xe0c8) (#Xe0cc . #Xe0cf) ;; (#Xe0d0 . #Xe0d2) #Xe0d4 (#Xe700 . #Xe7c5) (#Xf000 . #Xf2e0) ;; #X2665 #X26a1 (#Xf400 . #Xf4a8) #Xf67c ;; (#Xe000 . #Xe00a) (#Xf300 . #Xf313) (#Xe5fa . #Xe62b))

(mihara/attach-nerd-font) (add-hook 'after-make-frame-functions 'mihara/attach-nerd-font)

mohkale commented 2 years ago

Seems like a cool idea. It would probably simplify code-points and make it easier to customize but this only really works with somthing like nerd-fonts (if I'm understanding it correctly). There's still some font glyphs that aren't in nerd fonts (like emacs for one :cry:) so we still need something like all-the-icons that can work across multiple (perhaps conflicting) fontsets. Once this does happen though I see no issue with your suggestion, you might wanna raise it on all-the-icons as well when that happens.

Mihara commented 2 years ago

Technically, you could just use all the fonts all-the-icons installs and stitch them all together this way into the base font, as well. I am just not up to tracking down all the codepoints involved, right now, as even fishing them out of a single ttf file was a task that is slightly above my current understanding of fonts.