Installing custom fonts in Linux
— Kaushal ModiI’ll step through how to set custom fonts for xterm terminal. My default shell is tcsh
.
- Create a folder
.fonts
in your $HOME directory. - Download fonts of your choice (ttf or otf format to ~/.fonts).
- Refresh the fonts cache with
fc-cache -fv
. - You can verify if your custom fonts got added to the cache using
fc-list
. For example, I would dofc-list -f "%{family}\n" | sort -u | grep 'Inconsolata'
1 to check if my downloaded Inconsolata fonts got into the font cache. - Add the below .Xdefaults snippet to your
~/.Xdefaults
- Add
xrdb -merge $HOME/.Xdefaults
to your shell init script. My shell init script is~/.alias
.
*customization: -color
XTerm*termName: xterm-256color
xterm*saveLines: 500
xterm*scrollBar: false
xterm*cursorColor: white
xterm*pointerColor: white
xterm*Foreground: white
xterm*Background: black
xterm*c132: true
xterm*loginShell: false
! Fonts
! XTerm*faceName: DejaVu Sans Mono:size=11
! XTerm*faceName: Inconsolata:size=11
! XTerm*faceName: Inconsolata\\-dz:style=dz:size=11
XTerm*faceName: Inconsolata\\-g:style=g:size=11
Done! Now source your shell init script and launch xterm
.
Note: In order to use font names with hyphens in them, I had to escape them by using \\
. So for the Inconsolata-g
font, I have XTerm*faceName: Inconsolata\\-g:style=g:size=11
.
It might be helpful to add the below aliases to your tcsh init script for quick font refresh and check, using fontsrefresh; fontsavail | grep 'Inconsolata'
.
alias fontsavail 'fc-list -f "%{family}\n" | sort -u'
alias fontsrefresh 'fc-cache -fv'