Skip to content

Instantly share code, notes, and snippets.

@AndreaGhizzoni
Last active November 22, 2017 10:23
Show Gist options
  • Save AndreaGhizzoni/709377c943e13baa7dbfc6ac83817273 to your computer and use it in GitHub Desktop.
Save AndreaGhizzoni/709377c943e13baa7dbfc6ac83817273 to your computer and use it in GitHub Desktop.
installing_fonts.md

Installing fonts

Personal tutorial to properly install Powerline fonts and patch it with Nerd Fonts.

1. Install Powerline fonts

For me this set of font is required to display powerline symbols for vim-airline.

git clone https://github.com/powerline/fonts.git fonts
./fonts/install.sh
fc-cache -f

They will be placed in $HOME/.local/share/fonts.

2. Get Nerd Fonts

Clone Nerd Fonts repository:

cd ~/Documents
git clone --depth 1 https://github.com/ryanoasis/nerd-fonts.git nerd-fonts

Now select a font form $HOME/.local/share/fonts and make sure that ends with [..] for Powerline.[t/o]tf, for example DejaVu Sans Mono for Powerline.[t/o]tf and:

cd ~/Documents/nerd-fonts
cp ~/.local/share/fonts/DejaVu\ Sans\ Mono\ for\ Powerline.ttf .

Then patch it with font-patcher:

./font-patcher --complete --use-single-width-glyphs DejaVu\ Sans\ Mono\ for\ Powerline.ttf
  • --complete tells to font-patcher to add all available glyphs
  • --use-single-width-glyphs tells to font-patcher to use a single-width not double-width to generate glyphs

And as a result a new font file is generated:

ls
[...]
DejaVu Sans Mono for Powerline.ttf
DejaVu Sans Mono Nerd Font Complete Mono.ttf
[...]

Now DejaVu Sans Mono Nerd Font Complete Mono.ttf contain all available glyphs. Then copy in the right place and update font cache:

cp ~/Documents/nerd-fonts/DejaVu\ Sans\ Mono\ Nerd\ Font\ Complete\ Mono.ttf ~/.local/share/fonts
fc-cache -f

3. Change font to UXTerm

Font and settings of uxterm can be changed via $HOME/.Xresources file:

UXTerm*locale: true
UXTerm*renderFont: true
UXTerm*faceName: DejaVuSansMono Nerd Font Mono
UXTerm*faceSize: 9
*customization: -color

IMPORTANT: When using UXTerm*faceName: you specify a font name that is NOT equals to the file name in $HOME/.local/share/fonts. You can list all font name with:

fc-list | cut -f2 -d: | sort -u

So by listing all fonts face name with the previous command and grep it by DejaVu:

[...]
DejaVu Sans Mono for Powerline
DejaVuSansMono Nerd Font Mono
[...]

Our new font face name (generated in section 2) will be displayed with [...] Nerd Font Mono, in our example DejaVuSansMono Nerd Font Mono.

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