Skip to content

Instantly share code, notes, and snippets.

@gjazali
Last active April 28, 2025 08:21
Show Gist options
  • Save gjazali/fd39fa5ee09615042940c96b08d16f5a to your computer and use it in GitHub Desktop.
Save gjazali/fd39fa5ee09615042940c96b08d16f5a to your computer and use it in GitHub Desktop.

Adjusting the Grub Bootloader for a HiDPI Screen

The text size on Grub, when running on a computer with a HiDPI screen (e.g., 2880x1800 at 13 inch), will often appear too small. Lowering Grub's resolution is one solution. However, it will make Grub's interface pixelated. A better way is to enlarge the font size itself and not mess with the resolution.

We can start by deciding what font we want to use for Grub's interface. I recommend using a typeface that is specifically built for the absence of anti-aliasing, such as Unifont.

Changing the font size of Grub means replacing the binary .pf2 font file that is compatible with Grub (regular .ttf files can't be read by Grub). This is because the font size is hardcoded to the binary. To create that .pf2 file out of the Unifont typeface, we can run the following in the command line:

sudo grub-mkfont --no-hinting -s 32 -o /boot/grub/fonts/unifont.pf2 /usr/share/fonts/Unifont/Unifont.ttf

This will create a .pf2 file under the /boot/grub/fonts directory for Unifont with a size of 30 (as specified by the -s flag, which you can adjust accordingly). After that, we can add the following line to our Grub config file (usually /etc/default/grub).

GRUB_FONT="/boot/grub/fonts/unifont.pf2"

We can now update the Grub configuration by running:

sudo grub-mkconfig -o /boot/grub/grub.cfg

This command will update the /boot/grub/grub.cfg file that Grub will read from using the entries from /etc/default/grub.

If you see any gaps between the border characters in the Grub menu, try to resize the font by modifying the value of the -s argument. If you find that Heavy border characters are used instead of the Light ones, you can use tools like FontForge to copy over the Light characters into the codepoints of the Heavy characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment