Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Icons: The Masterplan #97

Closed
dritter opened this issue Sep 18, 2015 · 16 comments
Closed

Icons: The Masterplan #97

dritter opened this issue Sep 18, 2015 · 16 comments

Comments

@dritter
Copy link
Member

dritter commented Sep 18, 2015

As you requested in #91 , here is the masterplan to get to stable icons. I'll describe it here from the beginning, it may serve as possible explanation for other users.

Documentation

Introduction

This theme uses special icons to look fancy. So we need special fonts to display these special icons correctly. There are two ways to use these fonts:

  1. We can use pre-patched fonts. This is the preferred way for all POWERLEVEL9K_MODEs: default, compatible and awesome-patched.
  2. Every operating system has a mechanism to fallback to the correct fonts. This is a more complicated way to install the fonts, as usually extra software is necessary.

Here I focus on the first (pre-patched) way, because even this is the easier method, some parts must be understood.

Installation

Three parts play a role to display the theme correctly:

  1. The font itself: It must provide the correct glyphs that the theme wants to display.
  2. The terminal emulator: The font must be proper installed in the operating systems font manager and set in your terminal emulator (such as iTerm2, Konsole, Terminal, RxVT, etc.) as font.
  3. The theme: It prints special characters, representing a glyph in your font. As different fonts use (at least for these special characters) different code points, the theme needs to know which set of code points it should use. These sets are represented as POWERLEVEL9K_MODE.
    For the default-mode, you just need a powerline-patched font. For awesome-patched, you need a awesome-patched font.
    Unfortunately, there is no way to detect the used font automatically because the shell doesn't know much about how to render its content.

Masterplan

Far-future plan

As the awesome-terminal-fonts are not the only project which offer a broad range of pre-patched fonts and besides look somewhat inactive, I think the best would be to switch to nerd-fonts. They seem to be more active, have stable codepoints over different stategies, more icons. On the downside, they have some serious issues which need to be fixed first.
The other long-term solution could be to unify the codepoints in the different strategies in the awesome-terminal-fonts project.
Status: Open

Interim solution

awesome-terminal-fonts are currently problematic, as the relocate all codepoints regardless whether this is necessary or not. The result is that the fallback-, patched- and original fonts all have different codepoints. To relieve the pain a bit for our users, we could offer a new POWERLEVEL9K_MODE="awesome-fallback", which is a new set of codepoints in the icons-variable. I would think this could be the codepoints from master...tcbbd:master . This isn't a pretty solution, but the quickest.
Status: Done. See #108

@bhilburn I hope that helped to clear my plan up. ;)

@dritter
Copy link
Member Author

dritter commented Sep 22, 2015

@tcbbd: Do you want to implement the "interim solution"? You just need to merge your changes from master...tcbbd:master into the icons variable (key: awesome-fallback) in the next branch.
That would be cool.

@bhilburn
Copy link
Member

@dritter - So, to make this even more complicated, I think there are additional things we need to consider.

For example, I would bet many of our users use other programs that rely on specific code points, like vim-airline, or folks with fancy tmux configs now using powerline. All of these require the terminal to have the appropriate font set, and if we require a font that then breaks any of the code points in these other common programs, things are problematic.

Is the primary issue with nerd-fonts the unstable code points?

I also wonder if we could chat with the other developers working on these projects and coordinate something that makes sense. I believe the people involved would be:

Nerd Fonts: @ryanoasis
Powerline: @Lokaltog
Awesome Terminal Fonts: @gabrielelana

@ryanoasis
Copy link
Member

Let me know what I can do to help out. Cheers! 😄

@dritter
Copy link
Member Author

dritter commented Nov 1, 2015

Is the primary issue with nerd-fonts the unstable code points?

@bhilburn Not really. I made an issue up regarding unstable code points, but in total they are quite stable. font-awesome on the other hand has different code points for the different strategies and do a relocate by default (which is what I consider "unstable").
Further the nerd-fonts project emerged from a VI background AFAIK.

I think there is no good solution for this. The root cause is the use of private code points that lead to collisions between fonts, which we cannot prevent..
A good, flexible approach is the fallback-strategy from the freetype. But that helps us just in terms of flexibility. Collisions would appear here as well.

It is crucial for a font to stay as close as possible to the code points of the original font so that users could use different projects which require special fonts (e.g. tmux and vim-airline).

@ryanoasis
Copy link
Member

Further the nerd-fonts project emerged from a VI background AFAIK.

Yes, that is correct: https://github.com/ryanoasis/vim-devicons

I didn't know what I was getting into with customizing fonts 😈 it is both fun and frustrating... just like everything worth doing is I suppose 😆

@DanielGGordon
Copy link

I would also like to add the Windows users tend to get left in the dust. There is only a tiny set of fonts that seem to work on Mintty - which is used by Cygwin and Babun. And as far as I know, Cygwin/Babun is the only way you can get Zsh on Windows.

The font I am currently using is DejaVu Sans Mono for Powerline. It works for default just fine. But I haven't gotten any of the awesome or nerd fonts to display all symbols (tried many fonts).

So going forward, it would be nice to make sure there is some testing done on the Windows side (which I would be more than happy to do). Fonts that many people say work fine on Windows - usually still have some icons missing.

@ryanoasis
Copy link
Member

I am still alive 😜 but busy recently. Seems like getting the fonts working better (or just plain working at all) in Windows would be a priority. Thanks

@wadkar
Copy link
Contributor

wadkar commented May 17, 2016

Let me know if you need someone to test it out. I would really like to see nerd-fonts working on all platforms.

@ryanoasis
Copy link
Member

@wadkar

Let me know if you need someone to test it out

Short answer: Yes! 😄
Longer answer: I want to build something to help with testing (at least partially automated) or find something that will help. There are too many fonts now to test by hand per OS

I want to get it working better cross-platform too, I just don't really test much on Windows 😟 as much as I should and I do not currently have a Mac.

@DanielGGordon
Copy link

This will be really interesting also once the new Windows build comes out with new Linux subsystem.

@wadkar
Copy link
Contributor

wadkar commented May 19, 2016

@ryanoasis you can count me in for both MacOS and Ubuntu!
Maybe I will take a page out of @DanielGGordon and install the linux subsystem in one of the spare Windows machine I have.
Always a pleasure to help :)

@dgdosen
Copy link

dgdosen commented May 27, 2016

Related to all of this...

I've got nerd-fonts installed on mac os and used for non-ascii characters in iterm... and can see the awesome icons when I run an echo command. For example:

echo "\ue004"

I see the nerd-font patched pomodoro tomato...

When I try to use that same unicode in a custom format string for powerlevel9k, I see the unicode replacement black diamond and question mark. However, I'll also get a the awesome fonts for some unicode characters, like uf073. Not sure why that's inconsistent...

@lcorsini
Copy link
Contributor

lcorsini commented May 30, 2016

I'm actually wrestling with nerd-fonts in windows.
Sadly my best powerline font (Terminus/Terminess) doesn't work well with nerd-fonts patches (see ryanoasis/nerd-fonts#86) so I'm searching for another font to play with powerlevel9k

At the moment I've got good results with Hack/Knack but I had to rewrite a lot of icons because they are located at different points and a lot of them won't work in putty (I choose an icon in the character map and get a different letter or symbol, or nothing, on the terminal)
Here is some of my changes (didn't had time to fork you repo)

`
'nerd-fonts')
# Awesome-Patched Font required! See:
# https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
LEFT_SEGMENT_SEPARATOR $'\UE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\UE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
CARRIAGE_RETURN_ICON $'\U21B5' # ↵
ROOT_ICON $'\UE5FF' # 
RUBY_ICON $'\UE791 ' # 
PYTHON_ICON $'\UE606 ' # 
AWS_ICON $'\UF270' # 
AWS_EB_ICON $'\U1F331 ' # 🌱
BACKGROUND_JOBS_ICON $'\UE82F ' # 
TEST_ICON $'\UE891' # 
TODO_ICON $'\U2611' # ☑
BATTERY_ICON $'\UF241 ' #     
OK_ICON $'\UF273' # 
FAIL_ICON $'\UF274' # 
SYMFONY_ICON 'SF'
NODE_ICON $'\U2B22' # ⬢
MULTILINE_FIRST_PROMPT_PREFIX $'\U256D'$'\U2500'
MULTILINE_SECOND_PROMPT_PREFIX $'\U2570'$'\U2500 '
APPLE_ICON $'\UE26E' # 
FREEBSD_ICON $'\UF30E ' # 😈
LINUX_ICON $'\UE271' # 
SUNOS_ICON $'\UF185 ' # 🌞
HOME_ICON $'\UF015' #
HOME_SUB_ICON $'\UF414' # 
FOLDER_ICON $'\UE5FE' # 
NETWORK_ICON $'\UE1AD' # 
LOAD_ICON $'\UE190 ' # 
SWAP_ICON $'\UE87D' # 
RAM_ICON $'\UE1E2 ' # 
SERVER_ICON $'\UE895' # 
VCS_UNTRACKED_ICON '?'
VCS_UNSTAGED_ICON $'\u25CF' # ●
VCS_STAGED_ICON $'\u271A' # ✚
VCS_STASH_ICON $'\u235F' # ⍟
VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓
VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑
VCS_TAG_ICON ''
VCS_BOOKMARK_ICON $'\u263F' # ☿
VCS_COMMIT_ICON ''
VCS_BRANCH_ICON $'\uE0A0 ' # 
VCS_REMOTE_BRANCH_ICON $'\u2192' # →
VCS_GIT_ICON $'\UE709 ' # 
VCS_HG_ICON $'\UE1C3 ' # 
RUST_ICON ''
)
;;

`

It's unfinished and the comments doesn't reflect the actual glyph, but it's a good start for me
powerlevel9k

maybe there is some collision problem because of using different font sources, a good idea could be create a single glyph source from devicons,octoicons,pomodoro etc and a selection of the massive fontawesome

EDIT

Just to mention that the setup above works perfectly also on OSX, with iTerm2 I can choose my Terminus TTF (linked in the issue I wroke above) as main font, and Knack for non-standard glyph

On linux I still need to try, but fontconfig method was working, I have to check if the glyphs retain the same address

@bhilburn
Copy link
Member

bhilburn commented Dec 9, 2016

Hey @lcorsini! We wanted to check-in on how your nerdfont integration is going with PL9K. We were discussing whether or not it would be worthwhile to go ahead and try to get support for them merged into the upstream, and just specify a specific release until the codepoints stop churning. Based on your experience with them, what are your thoughts?

@lcorsini
Copy link
Contributor

lcorsini commented Dec 9, 2016

Hi,
I've experimented a lot with nerd fonts, at last I've been able to use them, at least on linux, by using fontconfig fallback, so I've forked pl9k here to add the different codepoints of them, and the results are quite good (and can be still configured to use powerline fonts) maybe it's not perfect, but it works ( you can see a screenshot here ryanoasis/nerd-fonts#84 (comment) )

@bhilburn
Copy link
Member

bhilburn commented Mar 8, 2017

Closing this one out since we have nerdfonts as of v0.6.0!

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

No branches or pull requests

7 participants