icons-in-terminal icon indicating copy to clipboard operation
icons-in-terminal copied to clipboard

Auto-detect terminals and their fonts

Open sebastiencs opened this issue 7 years ago • 26 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
  • [x] 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
  • [x] terminator link
  • [ ] Terminology link
  • [ ] Termite link
  • [ ] Tilda link
  • [ ] Tilix link
  • [ ] tinyterm link
  • [ ] urxvt link
  • [ ] xterm link
  • [ ] Yakuake link

sebastiencs avatar May 13 '17 21:05 sebastiencs

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.

BlitzKraft avatar Jul 25 '17 00:07 BlitzKraft

Works in tilix too. Thanks!

IvoLimmen avatar Jul 25 '17 05:07 IvoLimmen

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.

sebastiencs avatar Jul 26 '17 14:07 sebastiencs

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 avatar Jul 26 '17 19:07 BlitzKraft

@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

sebastiencs avatar Jul 27 '17 03:07 sebastiencs

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.

IvoLimmen avatar Jul 27 '17 04:07 IvoLimmen

Mac support would be awesome, in particular iTerm2!

amoriello avatar Jul 29 '17 04:07 amoriello

@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

sebastiencs avatar Jul 30 '17 14:07 sebastiencs

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 avatar Aug 06 '17 02:08 amoriello

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

sebastiencs avatar Aug 08 '17 09:08 sebastiencs

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

thomas-louvigne avatar Feb 28 '18 10:02 thomas-louvigne

It works also with xfce4-terminal

2018-02-28-111608_3600x1080_scrot

thomas-louvigne avatar Feb 28 '18 10:02 thomas-louvigne

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>

tybrs avatar Apr 25 '18 06:04 tybrs

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

thomas-louvigne avatar Jun 12 '18 14:06 thomas-louvigne

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?

pagerc avatar Jun 30 '18 05:06 pagerc

Can you please add support to kitty?

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

Maverobot avatar Dec 15 '19 01:12 Maverobot

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

BlitzKraft avatar Dec 15 '19 20:12 BlitzKraft

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.

drod3763 avatar Jul 13 '20 16:07 drod3763

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

chandrahmuki avatar Sep 07 '20 06:09 chandrahmuki

can i use it on windows 10 without WSL??

marzuk-zarir avatar Dec 29 '20 06:12 marzuk-zarir

Can you please add support to kitty?

Website: sw.kovidgoyal.net/kitty

Kitty seems to work fine for me.

jon4hz avatar Apr 26 '21 11:04 jon4hz

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

godalming123 avatar Dec 24 '21 14:12 godalming123

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

image

mladenp avatar Jan 19 '23 00:01 mladenp

Foot terminal font successfully installed through autodetect, works perfectly

Ehiffi avatar May 03 '23 09:05 Ehiffi

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

pataquets avatar Nov 14 '23 12:11 pataquets

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.

ttkingdom avatar Jan 05 '24 01:01 ttkingdom