I would like to install a custom TTF or OTF font on Ubuntu Server, but I don’t want to have to install a GUI or desktop environment. Is there a way to get this custom font (Fira Code Nerd Font) to be used as the terminal font for Ubuntu Server?
>Solution :
There are a couple of things you will need to do to make this work. So long as you don’t mind fiddling around with fonts, follow these steps:
I – Convert the .ttf font to a .psf
-
Install the
bdf2psfpackage:sudo apt install bdf2psf -
Convert the font to an intermediary
.bdf:otf2bdf -p 18 -r 96 -o fc-nerd.bdf fc-nerd.ttfNote: Be sure to replace
fc-nerdwith the actual font name.You may need to modify the
-pvalue to match the glyph size, as it’s not standard. -
Convert the
.bdfto a.psf:bdf2psf --fb fc-nerd.bdf /usr/share/bdf2psf/standard.equivalents /usr/share/bdf2psf/fontsets/Uni2.512 512 fc-nerd.psf -
Move the file to the appropriate location:
mv fc-nerd.psf /usr/share/consolefonts/fc-nerd.psf
II – Set the Font
- Use
setfontto configure the console:setfont fc-nerd
If the font doesn’t look right, go back to the first set of steps and modify that -p value until it looks better.
If you would like to use the font every time you sign into the console, you can add the setfont command to the end of your ~/.bashrc file.