sebastiencs / icons-in-terminal

Use any fonts in the terminal without replacing or patching
MIT License
984 stars 46 forks source link

Auto-detect terminals and their fonts #1

Open sebastiencs opened 7 years ago

sebastiencs commented 7 years ago

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

BlitzKraft commented 6 years ago

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.

IvoLimmen commented 6 years ago

Works in tilix too. Thanks!

sebastiencs commented 6 years ago

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:

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.

BlitzKraft commented 6 years ago

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".

sebastiencs commented 6 years ago

@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

IvoLimmen commented 6 years ago

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.

amoriello commented 6 years ago

Mac support would be awesome, in particular iTerm2!

sebastiencs commented 6 years ago

@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

amoriello commented 6 years ago

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.

sebastiencs commented 6 years ago

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

thomas-louvigne commented 6 years ago

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

thomas-louvigne commented 6 years ago

It works also with xfce4-terminal

2018-02-28-111608_3600x1080_scrot

tybrs commented 6 years ago

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>
thomas-louvigne commented 6 years ago

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

pagerc commented 6 years ago

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?

Maverobot commented 4 years ago

Can you please add support to kitty?

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

BlitzKraft commented 4 years ago

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

drod3763 commented 3 years ago

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.

chandrahmuki commented 3 years ago

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

marzuk-zarir commented 3 years ago

can i use it on windows 10 without WSL??

jon4hz commented 3 years ago

Can you please add support to kitty?

Website: sw.kovidgoyal.net/kitty

Kitty seems to work fine for me.

godalming123 commented 2 years ago

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

mladenp commented 1 year ago

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

image
Ehiffi commented 1 year ago

Foot terminal font successfully installed through autodetect, works perfectly

pataquets commented 7 months ago

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

ttkingdom commented 6 months ago

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.