2

Background: I am trying to create a custom theme for the GRUB bootloader using a specific font that I've generated myself. However, I'm encountering issues loading the font file.

Steps:

I generated the font with the following command:

sudo grub-mkfont --output=./DejaVuSansMono20.pf2 --size=20 /usr/share/fonts/TTF/dejavu/DejaVuSansMono.ttf

I attempted to load it in my theme.txt file, but it defaults to using the standard font, even though the text color settings are applied correctly.

Here's the relevant section of my theme.txt:

desktop-image: "background.png"
title-text: ""
terminal-box: "terminal_*.png"
terminal-left: "10%"
terminal-top: "25%"
terminal-width: "80%"
terminal-height: "50%"
  • boot_menu {

    left = 20% width = 60% top = 30% height = 40% item_font = "DejaVuSansMono20.pf2" item_color = "#808080" selected_item_font = "DejaVuSansMono30.pf2"" selected_item_color = "#ff0000"

}

What I have tried

I based my theme on another theme where the font is working, but it does not use the file name; instead, it uses a different name. I thought it might relate to the -n flag described here: https://manpages.ubuntu.com/manpages/noble/man1/grub-mkfont.1.html

Unfortunately, using the -n flag didn't resolve the issue. I also tried removing the fonts from the other theme, and as expected, they were not loaded, confirming that it does use the fonts from its directory.

Is there any documentation or guidance on how to properly create and load your own fonts for a GRUB theme? I've already looked through the official GRUB manual here: https://www.gnu.org/software/grub/manual/grub/html_node/Theme-file-format.html#Fonts, but it wasn't helpful for this issue.

System:

Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble

Tools

  • grub2-theme-preview 2.8.0 (used only to test the theme)
  • grub-install (GRUB) 2.12-1ubuntu7

Problems:

  • How to load a font file generated by grub-mkfont in a theme?
  • Is it possible to test a pf2 in any font viewer?

EDIT: I use Ubuntu version 24.04 and the grub boot-loader that came with the installation. I have downloaded some extra tools to edit the theme preview the bootloader theme.

1 Answers1

2

I found the answer my self.

I need to add the --verbose flag

sudo grub-mkfont --output=./DejaVuSansMono30.pf2 --size=30 /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf --verbose

Font name: DejaVu Sans Regular 30 Max width: 48 Max height: 39 Font ascent: 33 Font descent: 12 Number of glyph: 6288

This result in the I could see the "Font name" this is the name I should use in the theme.txt

+ boot_menu {
    menu_pixmap_style = "boot_menu_*.png"
    item_font = "DejaVu Sans Regular 30"
    ....

I got confused because menu_pixmap_style wanted file names, so its a mix. But here its just the name of the font. I suspected this due to other fonts that I looked at for reference where using the name.