Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Installing custom fonts on Ubuntu Server

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

  1. Install the bdf2psf package:

    sudo apt install bdf2psf
    
  2. Convert the font to an intermediary .bdf:

    otf2bdf -p 18 -r 96 -o fc-nerd.bdf fc-nerd.ttf
    

    Note: Be sure to replace fc-nerd with the actual font name.

    You may need to modify the -p value to match the glyph size, as it’s not standard.

  3. Convert the .bdf to a .psf:

    bdf2psf --fb fc-nerd.bdf /usr/share/bdf2psf/standard.equivalents /usr/share/bdf2psf/fontsets/Uni2.512 512 fc-nerd.psf
    
  4. Move the file to the appropriate location:

    mv fc-nerd.psf /usr/share/consolefonts/fc-nerd.psf
    

II – Set the Font

  1. Use setfont to 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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading