Adding a GRUB2 background image and custom font

I am trying to use grub-customizer to add a custom background image and use the Ubuntu Condensed font. The preview looks fine:

enter image description here

But when I actually boot up, I get a messed-up configuration. The text is messed-up, with "unknown character" symbols appearing for the box around the boot menu options (because apparently only the default grub font has these special characters?). However, the boot options are in the Ubuntu font. There is only a black screen as the background.

I'm trying to use a 1366x768 (same as my screen res) .png as the background image. This should be compatible, right? What can I do to get a background image working?

Sorry for the wait:

Boot screen closeup showing glitched Ubuntu font and unrecognized charactersEntire screen


Solution 1:

Info about changing GRUB font to Ubuntu-Mono that I should have found earlier:

In this question, OP tried to change font without results. Problem appears to be a bug with ascending order glyphs as per this answer.

So basically I can't use anything from the Ubuntu Font Family for my GRUB font (sad but true) until the bug is fixed.

Info about background image:

If no option is specified in /etc/default/grub, GRUB will use the first found image in /boot/grub. The image must in RGB colorspace and, if a JPEG, 8-bit. GRUB will automatically detect the screen resolution, no configuration needed, and stretch/shrink the image if necessary (from thegeekstuff.com).

So to sum up, all that was needed was for me to just go with the default font (no way around it) and edit my image in GIMP to fit the parameters.

Solution 2:

Grub Themes

The problem may have been caused by a grub customizer bug. An alternative to grub customizer (a third party program) is to use grub-themes which comes standard on every Ubuntu installation:

Grub Boot


Make Grub fonts

Even if you are just using regular grub, if you want a different font you must use grub-mkfont program first. The same holds true for Grub Customizer used by OP and Grub Themes used in first section of this answer.

Here are the fonts I have made for grub to use:

$ ll /usr/share/grub/themes/Tuxkiller2/*.pf2
-rwxrwx--- 1 root root 176923 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/dejavu_14.pf2*
-rwxrwx--- 1 root root  20041 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/droidlogo_bold_17.pf2*
-rwxrwx--- 1 root root  23339 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/droidlogo_bold_20.pf2*
-rwxrwx--- 1 root root  31498 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/droidlogo_bold_26.pf2*
-rwxrwx--- 1 root root  15244 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/droidlogo_regular_12.pf2*
-rwxrwx--- 1 root root  19148 Jun  9 16:41 /usr/share/grub/themes/Tuxkiller2/droidlogo_regular_17.pf2*
-rwxrwx--- 1 root root 113623 Jul 11 17:05 /usr/share/grub/themes/Tuxkiller2/ubuntu_bold_italic_36.pf2*
-rwxrwx--- 1 root root  45391 Jul 11 17:08 /usr/share/grub/themes/Tuxkiller2/ubuntu_light_20.pf2*
-rwxrwx--- 1 root root  41020 Jul 11 17:16 /usr/share/grub/themes/Tuxkiller2/ubuntu_regular_18.pf2*
-rwxrwx--- 1 root root  46423 Jul 11 17:16 /usr/share/grub/themes/Tuxkiller2/ubuntu_regular_20.pf2*
-rwxrwx--- 1 root root  68602 Jul 11 16:59 /usr/share/grub/themes/Tuxkiller2/ubuntu_regular_28.pf2*

To create a font use the grub-mkfont program like this guide outlines: Increase Font in GRUB for High DPI Screens:

sudo grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono24.pf2 \
  --size=24 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Then in your /etc/default/grub configuration file tell it to use the new .pf2 font file:

# More readable font on high dpi screen, generated with
# sudo grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono24.pf2 \
#    --size=24 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
GRUB_FONT=/boot/grub/fonts/DejaVuSansMono24.pf2

Finally run:

sudo update-grub

Reply to comment: Grub themes are built into grub so use:

$ apt policy grub2-common
grub2-common:
  Installed: 2.02~beta2-36ubuntu3.18
  Candidate: 2.02~beta2-36ubuntu3.18
  Version table:
 *** 2.02~beta2-36ubuntu3.18 500
        500 http://ca.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.02~beta2-36ubuntu3 500
        500 http://ca.archive.ubuntu.com/ubuntu xenial/main amd64 Packages