Fonts

GRUB uses its own font format, created using grub-mkfont tool. You can create the font based on the existing fonts in your operating system. Keep in mind that GRUB doesn't use vector type fonts but complies to the “PFF2 font format” bitmap fonts. This is to reduce the GRUB footprint and pre-render any fonts into images for performance and speed.

Therefore, if you want to scale (change font size), you need to re-create your bitmap font again. Be creative.

You can also use lsfont and loadfont commands to search and load your font. If there are multiple fonts required for simultaneous loading, you can:

grub> lsfont
....
grub> set pager=1
grub> loadfont /path/to/font

Create GRUB Font

GRUB don't use kerning format. To convert it, use:

$ grub2-mkfont INPUT_FONT [optional parameters] --output OUTPUT_FONT.pf2

OR 

$ grub-mkfont INPUT_FONT [optional parameters] --output OUTPUT_FONT.pf2

There are a list of parameters to use:

  • -o /path/to/file.pf2, --output=/path/to/file.pf2 - Compulsory. The output path with file extension .pf2.
  • -v, --verbose - Optional. Display details about the created font.
  • -n NAME, --name=NAME - Optional. Set the font's name. Default is following the template: FONT_NAME TYPE SIZE.
  • -s NUM, --size=NUM - Optional. Default is 16.
  • -b, --bold - Optional. Output the font in bold.
  • -c NUM, --asce=NUM - Optional. Only output the ascent of the font. See picture.
  • -d NUM, --desc=NUM - Optional. Only output the descent of the font. See picture.
  • --ascii-bitmaps - Optional. Only encode ASCII symbols.
  • -r FROM-TO[,FROM-TO], --range=FROM-TO[,FROM-TO] - Optional. Only encode symbols within range.
  • -V, --version - Optional. Show current grub2-mkfont version.


Examples

$ grub-mkfont -s 32 -o /boot/grub/fonts/unicode.pf2 /usr/share/fonts/truetype/unifont/unifont.ttf 
$ sudo grub2-mkfont -s 14 -o /boot/grub2/DejaVuSansMono.pf2 /usr/share/fonts/dejavu/DejaVuSansMono.ttf

Deploy

Once you have your file created, you should store it inside your theme directory for deployment.

/boot/grub/themes/<your_theme>/myfont.pf2


In your grub.cfg, declare the grub font. That should do it.

GRUB_FONT=/boot/grub/themes/<your_theme>/myfont.pf2
Fonts - ascent and descent sections

That's all about fonts.