sebastiencs / icons-in-terminal

Use any fonts in the terminal without replacing or patching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto-detect terminals and their fonts

sebastiencs opened this issue · comments

List of supported terminals for auto generating a good fontconfig file.

  • If your terminal isn't supported yet, comment this issue to tell me where to lookup its font familly, PR are welcome (see scripts/detect_font_terminal/).
  • If your terminal is listed as supported but the script install-autodetect.sh fails, please comment this issue.

  • aterm link
  • Cool Retro Term link
  • Eterm link
  • evilvte link
  • Gate One link
  • Germinal link
  • GNOME Terminal link
  • Guake link
  • Konsole link
  • LilyTerm link
  • LXTerminal link
  • MATE terminal link
  • mlterm link
  • Pantheon Terminal link
  • QTerminal link
  • ROXTerm link
  • rxvt link
  • sakura link
  • shellinabox link
  • st link
  • Terminal link
  • terminator link
  • Terminology link
  • Termite link
  • Tilda link
  • Tilix link
  • tinyterm link
  • urxvt link
  • xterm link
  • Yakuake link
commented

You can add fbterm to the list of supported terminals. I installed this using install-autodetect.sh (for gnome-terminal) and all the glyphs show up nicely in fbterm too.

Works in tilix too. Thanks!

Hi @BlitzKraft and @IvoLimmen, I didn't write any script to autodetect the fonts in tilix or fbterm.
There could be 2 reasons why it works with you:

  • You're using the same font in tilix/fbterm and gnome-terminal (or terminator, the only 2 supported)
  • You have no other fonts in your system with glyphes inside the private use areas, so freetype look for glyph in all the others fonts of your system until finding one in icons-in-terminal.ttf

I recommend you to check the file .config/fontconfig/conf.d/30-icons.conf to see if the font you're using in tilix/fbterm is listed. If not, please add the font name to the list.

commented

I checked the config, it just says "No font found". Here is the full xml doc:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias><family>No font found</family><default><family>icons-in-terminal</family></default></alias>
</fontconfig>

So, I must be missing something. The font I am using in gnome-terminal is "Hack". I also tested with Iosevka (patched for powerline) and that doesn't work. Many symbols show up with "missing glyph squares".

@BlitzKraft I've open an issue about that #7

In the meantime, you can run install.sh, it will replace .config/fontconfig/conf.d/30-icons.conf. Edit this file to remove all the lines but the ones with 'Hack' and the font you're using in fbterm

Mine says:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias><family>Droid Sans Mono for Powerline</family><default><family>icons-in-terminal</family></default></alias>
  <alias><family>No font found</family><default><family>icons-in-terminal</family></default></alias>
</fontconfig>

I use the Hack font. Demo did just fine.

Mac support would be awesome, in particular iTerm2!

@amoriello I don't have a Mac so I can't help.
Can you try this method and tell me if it works ? I will adapt it to icons-in-terminal if you confirm it

Hey Seb,

I finally found cycles to look at this.
The tutorial you pointed out worked just fine (iTerm2 3.0.15), thanks.

Just replace the section about editing Plist that says:

add a new row and type in Pomodoro. Do this three more times for FontAwesome, Octicons, and Icomoon

to

add a new row and type in icons-in-terminal.

I've attached the screenshot to help you making this.


Regarding print_icon.sh

This stuff just doesn't work for me, it prints the unicode code point instead of the icon.

capture

I did not took time to look in this shell madness of yours 😜 , so I made a quick python script to ensure the fallback mechanism is working properly:

#!/usr/bin/env python3

'''
check_icons.py
'''

import os
from collections import namedtuple

IconInfo = namedtuple('IconInfo', ['name', 'code'])
FontInfo = namedtuple('FontInfo', ['name', 'num_entries'])

def banner(text, width=80):
    ''' Just a banner
    '''
    title = ' '.join(text.upper()).center(width)
    print('#' * width)
    print('%s' % title)
    print('#' * width)

def icons_info(line):
    ''' Generator over icons in line
    '''
    icons = line.split(';')
    for icon in icons[:-1]:
        yield IconInfo(*icon.split(':'))

def fonts_info(mapping):
    ''' Generator over fonts and their icons
    '''
    for line in mapping:
        if line.startswith('#'):
            font_info = FontInfo(*line[1:].split(':'))
            continue
        yield font_info, icons_info(line)

def main():
    ''' main
    '''
    mapping = open('./build/mapping.txt', 'r')
    columns = int(os.popen('stty size', 'r').read().split()[1])
    for font_info, icons in fonts_info(mapping):
        banner(font_info.name, width=columns)
        for icon in icons:
            print('%s  ' % chr(int(icon.code, 16)), end='')
        print('\n' * 3)

if __name__ == '__main__':
    main()

working


Tutorial Screenshots

Font book

fontbook

Plist

plist

Finder

finder

Cheers.

@amoriello Thank you very much for your help !
I will update the readme and include your pictures.
Good to know it works on Iterm

it works perfectly on sakura
2018-02-28-110841_3600x1080_scrot

It works also with xfce4-terminal

2018-02-28-111608_3600x1080_scrot

I just see a bunch of boxes on Urxvt (however terminator works on the same system). Font family is in Xrerouces URxvt.font: xft:Noto Mono:size= 14

30-icons.conf below:

<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias><family>Noto Mono</family><prefer><family>icons-in-terminal</family></prefer></alias>
</fontconfig>

It don't work for me on xterm & uxterm. (But i don't hard try)
But it work on termite very well. https://github.com/thestinger/termite

WSLtty on Windows 10 doesn't play nice with auto or manual installation.
I'm guessing fontconfig can't update the terminal font via device control codes?

Can you please add support to kitty?

Website: https://sw.kovidgoyal.net/kitty/

commented

Konsole works nicely. It can be checked off. I tested on konsole version 19.08.3. Installed using the install.sh script.

Just want to say the walkthrough posted for MacOS no longer works in Catalina. The DefaultFontFallbacks.plist has either moved or been replaced with some other solution so people on that repo are moving back to Patched Fonts.

hello to all ,

i did everything i could and followed as well the post...im using kitty the test does work im using hack as my main font ...if i test it in the terminal i can see all the glyphs but whatever im doing ...theres no way to have the icons displayed in nnn ...did i miss something ?? thanks for your help

can i use it on windows 10 without WSL??

Can you please add support to kitty?

Website: sw.kovidgoyal.net/kitty

Kitty seems to work fine for me.

could you add alacritty to the list of terminals that need supporting

The solution mentioned doesn't work for me on MacOS 13.1 for iterm as there is no DefaultFontFallback.plist:

image

commented

Foot terminal font successfully installed through autodetect, works perfectly

@sebastiencs Fancy to add Alacritty as suggested by @godalming123 previously?

Hey Seb,

I did not took time to look in this shell madness of yours 😜 , so I made a quick python script to ensure the fallback mechanism is working properly:

@amoriello Do you know any reason why print_icons.sh shows only the code points, but your Python script successfully shows the icons?

I'm using macos sonoma, Iterm2, and zsh shell.