Skip to content
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

Auto-detect terminals and their fonts #1

Open
2 of 30 tasks
sebastiencs opened this issue May 13, 2017 · 26 comments
Open
2 of 30 tasks

Auto-detect terminals and their fonts #1

sebastiencs opened this issue May 13, 2017 · 26 comments

Comments

@sebastiencs
Copy link
Owner

sebastiencs commented May 13, 2017

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
@BlitzKraft
Copy link

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
Copy link

Works in tilix too. Thanks!

@sebastiencs
Copy link
Owner Author

sebastiencs commented Jul 26, 2017

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.

@BlitzKraft
Copy link

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
Copy link
Owner Author

@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
Copy link

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
Copy link

Mac support would be awesome, in particular iTerm2!

@sebastiencs
Copy link
Owner Author

@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
Copy link

amoriello commented Aug 6, 2017

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
Copy link
Owner Author

sebastiencs commented Aug 8, 2017

@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
Copy link

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

@thomas-louvigne
Copy link

thomas-louvigne commented Feb 28, 2018

It works also with xfce4-terminal

2018-02-28-111608_3600x1080_scrot

@tybrs
Copy link

tybrs commented Apr 25, 2018

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
Copy link

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
Copy link

pagerc commented Jun 30, 2018

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
Copy link

Can you please add support to kitty?

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

@BlitzKraft
Copy link

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

@drod3763
Copy link

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
Copy link

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
Copy link

can i use it on windows 10 without WSL??

@jon4hz
Copy link

jon4hz commented Apr 26, 2021

Can you please add support to kitty?

Website: sw.kovidgoyal.net/kitty

Kitty seems to work fine for me.

@godalming123
Copy link

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

@mladenp
Copy link

mladenp commented Jan 19, 2023

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

image

@Ehiffi
Copy link

Ehiffi commented May 3, 2023

Foot terminal font successfully installed through autodetect, works perfectly

@pataquets
Copy link

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

@ttkingdom
Copy link

ttkingdom commented Jan 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests