I installed starship to have a nice looking prompt once and for all.
A first sight, it did not look that nice to me:
This is the Unicode character of a snake: 0x01F40D (🐍).
By looking at the documentation, starship claims that
Prerequisites:
A Nerd Font (opens new window)installed and enabled in your terminal (for example, try the Fira Code Nerd Font (opens new window)).
So I tried installing the Fira Code Nerd Font
, following the instructions in
how to manually install, update, and uninstall fonts on linux.
But nothing changed…
The font is slightly different, but still no emoji.
Fortunately, there is a tool to find out what installed fonts have what Unicode character.
So, I tried
fc-list :charset=01F40D
And got not result. This is coherent with the fact the character does not show up.
I asked a friend using a working starship to run this command and he got
> fc-list :charset=01F4A0
/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf: Noto Color Emoji:style=Regular
Sounds interesting, should I install this font? Let’s try.
sudo apt install fonts-noto-color-emoji
And magic!
After all, it looks like I don’t need to install a Nerd font at all.
Adapting the script from a stack overflow question, I can find out whether the snake character is in the font.
from itertools import chain
from fontTools.ttLib import TTFont
from fontTools.unicode import Unicode
print(f"Scanning {path}")
ttf = TTFont(path, 0, verbose=0, allowVID=0,
ignoreDecompileErrors=True,
fontNumber=-1)
chars = chain.from_iterable([y + (Unicode[y[0]],) for y in x.cmap.items()] for x in ttf["cmap"].tables)
for char in chars:
if "snake" in char[2].lower():
print(char)
# Use this for just checking if the font contains the codepoint given as
# second argument:
#char = int(sys.argv[2], 0)
#print(Unicode[char])
#print(char in (x[0] for x in chars))
ttf.close()
Scanning /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf
(128013, 'u1F40D', 'SNAKE')
It is indeed the character 0x01F40D.
Let’s try to find it in the suggested font Fira Code Nerd Font
. I get:
Scanning /home/sam/perso/konixwork/share/fonts/Fira Code Regular Nerd Font Complete.ttf
There is no snake showing up.
As a conclusion, I don’t understand why the prerequisite of starship is a nerd font while everything is fine why a standard font. Either way, I need a font with emoji because it uses them a lot.
Also, I found out why did this font get used while I did not tell my system to use it, but this is another story.