-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
Support Nerdfont Icons #333
Comments
This might be a dumb question but what's exactly the goal ? |
This is not dumb at all, I think I didn't elaborate enough. This would make icons work for many people (which use a Nerd Font in ther terminal anyway) 'out of the box', thereby removing the dependency of / the extra step needed to copy the vscode font. |
Nerd font is woefully deficient when it comes to file icons... Besides the copy step, there is no other work required. |
it's probably mostly about the copying, maybe my approach is not the best. Projects like nnn and exa seem to include the icons with the build. |
|
yes, I know. It's not htat hard to do, I'm just whining around 😅 no seriously: I thought that maybe that could be even more easier and low-barrier but the deficiency when it comes to files icons is a good point. Adding them during the build might be a nice thing but of course it's not necessary! |
I think it is worth keeping this feature request issue open for adding an First, the current icon setup on macOS requires some additional steps due to some overlap in Apple's San Francisco font, e.g. Also, the vscode font also ends up installing as "Untitled1" font. Getting it to work on Kitty ends up requiring a Kitty symbol map config like:
There may be some other ways to manipulate macOS's per-app font priorities that I am not aware of. Another advantage would be to have a general consistency of icons aesthetic (in some cases, it may not be the same icon since each tool reimplements mapping) across the terminal. The relates to how many tools usually have some support for nerd-fonts, e.g.:
|
I haven't read the entire thing, and I am not familiar with how font priorities work on machinetosh but for me on Linux kitty works just fine without any mapping required. It looks to me that SFCompact is using private space fonts on machinetosh-OS and that's obviously going to be problematic, no matter which font you use. How do you know nerdfont doesn't (and won't tomorrow) clash with machinetosh's use of private space? |
@asdf8dfafjk e.g. from iTerm2
Notes on terminals below. iTerm2There is no support for multiple font selection (https://gitlab.com/gnachman/iterm2/-/issues/9073), which would mean the user may have to do one of:
Default macOS Terminal.appI think this has same limitations of iTerm2 KittyUsing The only problem right now is the missing font metadata, resulting in the font being called "Untitled1": HyperIt looks like it supports fallback fonts via AlacrittyI don't know Alacritty's status on font configuration right now. Based on quick skim through alacritty/alacritty#957, it looks like there is mainly support for system font order for macOS (fontConfig on Linux), which ends up back to same issues as iTerm2. EDIT: Additional terminal details, linking external issues, limitations |
That's very well written text I must say. I haven't read much of it since I don't have a machinetosh machine but I can help you by telling you the steps required to support There are two main directories involved: https://github.com/Canop/broot/tree/master/src/icon and https://github.com/Canop/broot/tree/master/resources In the former (code), edit mod.rs, and In the latter (resources) Start by making Copy these 4 files You should get a sense of the files easily but to help you, the last file there maps a "<icon name (that you would generate as you please with no connection to anything)>" to a unicode point in nerdfont. You obviously already seem facile enough with unicode stuff so that latter is going to be easy. Then appropriately in the first 3 files map the entity to the icon name you just generated. |
@asdf8dfafjk Thanks for info. I'll see if I have some time to try creating a mapping. I did try mapping a few, and do see it working in local build: EDIT: For anyone who sees this issue, current work - https://github.com/cho-m/broot/tree/nerdfont-icons/resources/icons/nerdfont |
I took a quick look, you're on the right track. (Just remove the duplication across vscode and nerdtree before PR). |
This is false, at least on Arch Linux, using Plasma desktop. I have no idea how the right characters are expected to be found, but AFAICT the "proper" thing to do is use fontconfig to set the new, woefully named "Untitled1" font, as a fallback for at least the mono category. Example ~/.config/fontconfig/fonts.conf<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.local/share/fonts</dir>
<dir>/usr/share/fonts</dir>
<match target="font">
<edit mode="assign" name="autohint"><bool>false</bool></edit>
<edit mode="assign" name="hinting"><bool>false</bool></edit>
<edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
<edit mode="assign" name="lcdfilter"><const>lcddefault</const></edit>
<edit mode="assign" name="rgba"><const>rgb</const></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>monospace</string></test>
<edit name="family" mode="assign" binding="same"><string>Iosevka Term Custom</string></edit>
<edit name="family" mode="append" binding="weak"><string>Symbols Nerd Font</string></edit>
<edit name="family" mode="append" binding="weak"><string>JoyPixels</string></edit>
<edit name="family" mode="append" binding="weak"><string>Untitled1</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>serif</string></test>
<edit name="family" mode="assign" binding="same"><string>Quando</string></edit>
<edit name="family" mode="append" binding="weak"><string>Symbols Nerd Font</string></edit>
<edit name="family" mode="append" binding="weak"><string>JoyPixels</string></edit>
<edit name="family" mode="append" binding="weak"><string>Untitled1</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>sans-serif</string></test>
<edit name="family" mode="assign" binding="same"><string>Convergence</string></edit>
<edit name="family" mode="append" binding="weak"><string>Symbols Nerd Font</string></edit>
<edit name="family" mode="append" binding="weak"><string>JoyPixels</string></edit>
<edit name="family" mode="append" binding="weak"><string>Untitled1</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>emoji</string></test>
<edit name="family" mode="assign" binding="same"><string>Symbols Nerd Font</string></edit>
<edit name="family" mode="append" binding="weak"><string>JoyPixels</string></edit>
<edit name="family" mode="append" binding="weak"><string>Untitled1</string></edit>
</match>
</fontconfig> In my personal aversion to XML (especially because Plasma reformats this file to make it less legible to me), I generate that using vars.ymlroles:
monospace:
- Iosevka Term Custom
- Symbols Nerd Font
- JoyPixels
- Untitled1
serif:
- Quando
- Symbols Nerd Font
- JoyPixels
- Untitled1
sans-serif:
# - Barlow Medium
# - Baloo 2 Medium
- Convergence
- Symbols Nerd Font
- JoyPixels
- Untitled1
emoji:
- Symbols Nerd Font
- JoyPixels
- Untitled1
options:
autohint: 'false'
hinting: 'false'
hintstyle: hintnone
lcdfilter: lcddefault
rgba: rgb
fonts.conf.wz@require(roles, options)
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.local/share/fonts</dir>
<dir>/usr/share/fonts</dir>
<match target="font">
@for key, val in options.items():
@(otype = 'bool' if val in ('true', 'false') else 'const')\
<edit mode="assign" name="@key"><@otype>@val</@otype></edit>
@end
</match>
@for role, prefs in roles.items():
<match target="pattern">
<test qual="any" name="family"><string>@role</string></test>
<edit name="family" mode="assign" binding="same"><string>@{prefs[0]}</string></edit>
@for pref in prefs[1:]:
<edit name="family" mode="append" binding="weak"><string>@pref</string></edit>
@end
</match>
@end
</fontconfig> And this (Zsh) command: $ wheezy.template fonts.conf.wz =(yaml-get -p . vars.yml) >fonts.conf |
I needed a fontconfig entry too to make it work in more terminals. Some (like Wezterm) still refuse to display those symbols, but that's not a broot issue. Giving it a proper TTF name instead of Untitled1 makes it a bit nicer too:
Tool is available here: |
On that note, I came across this https://old.reddit.com/r/i3wm/comments/y48a61/nerdfonts_cheatsheet_offline/ if someone is working on the nerdfont thing. @cbirchinger Surprised that fc-cache (fontconfig cache updater) wasn't enough. In any case, the steps I mention are somewhat complete (to my knowledge) in the sense that any application using fontconfig should be able to fall back to vscode fonts . I do not know how wezterm and co make their font rendering decisions. |
I use a modified version or urxvt with 3 fonts:
To add a font for Urxvt the width needs to be adapted first, then fc-cache and addition to the conf. So it's not an easy process. But thanks to a large usage of Nerdfont icons on other projects I have icons in exa, vifm and others out of the box now. Broot seems nice so I will try to modify the vscode.ttf. But adding NerdFont would be nice. |
In my case vscode.ttf width is too irregular, and even after processing it with monospacifier some icons are still too width. I fixed other fonts like symbola with this technique. Most fonts generated with --mono in NerdFont are correct. |
@tkapias Please consider reading the entire discussion, that would help I think. |
@asdf8dfafjk I should have read a little more the part about I will do something else. I will update the method/ressources here soon. |
Please do not hesitate to ask for help. Happy to guide you over chat as well. |
So I'm not an expert I have to admit but on linux, my understanding is that the final "rendering" is provided by font config, and if a GUI app uses font config then there shouldn't be any additional work. I mean I've only done fc-cache on my computer but fontconfig allows for easy fallbacks. Here are some of my notes on fontconfig, please see if they help you. Two systems fontconfig vs XSETTINGS. More here: http://neugierig.org/software/chromium/fonts/ fontconfig http://www.linuxfromscratch.org/blfs/view/svn/x/tuning-fontconfig.html /etc/fonts For Monaco absolutely important: Pretty important: After adding fonts, or changing font configfc-cache -fvr --really-force ~/.fonts Find font installed for languagesfc-list -f '%{file}\n' :lang=zh Find font that contains a characterfc-match -s monospace:charset=1F4A9 Find font that matches a style 'sans', 'serif', 'cursive'fc-match -s 'sans' Find all points supported by a fontfc-query <filename.ttf> Take the 8 bits off the symbol you're looking for- Find fonts that supply a languagefc-list ":lang=zh-CN:scalable=true" family Language differenceFC_DEBUG=4 pango-view --language=ja_JP --text 語 XSETTINGS Wherever you see Xft, that's XSETTINGS. Firefox is weird DISPLAY FONT:
|
On that note, next time you encounter a character that's too wide, could you paste it here? I would likely do nothing right away but if I take a look at this again, I would see what I can do. |
if someone starts working on implementing nerdfonts again. I created a updated icon_theme: "nerdfont" setting for the current master branch in: https://github.com/JonasLeonhard/broot with nerdfont translations for all icons i could find. Thanks cho-m for the inspiration! Someone should probably double check the icons though. |
Thank you so much! It seems to work really well. Now I can get rid of those vscode icons. |
@Canop Candidate for PR? |
If you think it's good and doesn't introduce licensing problems, then a PR would probably be welcome. |
The patched fonts maintainer stays on top of licensing 👍🏼
@JonasLeonhard Still interested? |
Heyho everyone, I've been using the nerdfont version of my master branch ever since i made the comment in this thread. In its current state, the nerdfont setting works good enough for my use cases. However, I believe it is not quite ready for production. Certain icon mappings, such as "folders, .json .gitignore, markdown, rust and others" function as expected. Conversely, icons like ".js, .vue, .go, .jsx" currently display a generic file icon and require proper mapping. That beeing said, i will try to work on this when i find some time. |
This commit adds "icon_theme: nerdfont" as a setting to the broot conf.hjson file. 1. In order for the nerdfont setting to work you need to have a patched font installed. See: https://github.com/ryanoasis/nerd-fonts 2. After a successful installation, you need to add "icon_theme: nerdfont" to your broot conf.hjson file: ```hjson icon_theme: "nerdfont" ``` 3. Congratulations! You should now be able to see icons when opening broot in your terminal. This commit adds a new NerdfontIconPlugin to icon/mod.rs. The structure of the plugin is based on the existing vscode icon plugin. It maps incoming filenames based on mappings inside of icons/nerdfont/data/*_map.rs files. The iconset is limited by available nerdfont icons. Some icons simply don't exist as of yet. Eg. a vite or prettier icon. Thank you for putting me into the right direction: - Canop#333 (comment) - Canop#333 (comment)
Good news everyone. The first version of the "icon_theme: nerdfont" settings is now available for testing. I added a "icon_theme: nerdfont" setting to the broot conf.hjson file. I would love for someone to test this branch before i create a pull request! InstallationBranch:
How it works:This commit adds a new NerdfontIconPlugin to icon/mod.rs. The structure Limitations:The iconset is limited by available nerdfont icons. Some icons simply How to do i test this?
I found a file that is not mapped or wrongly mapped!Lets say you find some file icon you think i forgot or mapped wrong. Please go to https://www.nerdfonts.com/cheat-sheet and search for an icon you would like to set in its place. In order to correctly fix the icon mapping i need: <FILE_EXTENSION> and <NERDFONT_ICON_CODE>. Lets say you think the .json icon is incorrect.
Credits:Thank you for putting me into the right direction: Screenshots |
@JonasLeonhard Can you open a PR for line by line feedback? I looked over your changes previously but that'd be preferable for review and refining scope. Feel free to enable draft mode if you consider it WIP! |
accepting paths (Canop#333, Canop#833) this applies the refactor suggestion by texastoland: Canop#833 (comment) This commit - renames the existing VsCodeIconPlugin into FontPlugin. The only change made to the plugin is in the new() function. It now accepts a reference to an !included static array of touples as found in the icon_name_to_icon_codepoint_map, double_extension_to_icon_name_map, extension_to_icon_name_map and file_name_to_icon_name_map. This should be easier to maintain than two seperate plugin files.
Can be closed 🚀 |
I think it would make sense to support Nerd Fonts icons since many other CLI tools use them already.
The text was updated successfully, but these errors were encountered: