Use "Uni3-DejaVu43x24" font from the "console-setup" package as GRUB2 font with "grub2-mkfont" command

Hi I want to use the Uni3-DejaVu43x24 font from the console-setup package as my Grub2 font. I have already tried this font as a console font and it works great on my 4k laptop display as a console font; it is the perfect size.

I did the following to extract this font into the /usr/lib/kbd/consolefonts/ directory.

dnf download console-setup
rpm2cpio console-setup-1.230-1.fc41.noarch.rpm | cpio -i --to-stdout ./usr/share/consolefonts/Uni3-DejaVu43x24.psf.gz > /usr/lib/kbd/consolefonts/Uni3-DejaVu43x24.psf.gz

How do I make this font into a Grub2 font so I can use this font with Grub2? What changes do I need to make to /etc/default/grub?

Here is my current /etc/default/grub:

wiking@walhalla:~$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_GFXMODE=1280x720
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-82adf451-f027-4115-9dd7-46575fb4a044 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_THEME="/boot/grub2/themes/polylight/theme.txt"

I use these two lines, presently, to make the font size large enough on my 4k display, but of course the fonts look a little bit fuzzy at 1280x720 resolution:

GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_GFXMODE=1280x720

You can see an image of what the 43 point font looks like in this thread. It’s a good size:

https://discussion.fedoraproject.org/t/4k-monitor-cannot-read-text-in-rescue-kernel/

  1. First you need to convert the psf file to a pf2 file, which is what Grub uses. I’m not sure which utility you can use for that. Alternatively you can convert an existing ttf file per the example that @steppybug gave.

  2. Copy the font to /boot/grub2/fonts/DejaVuSansMono.pf2

  3. Then add the font to /etc/default/grub:

GRUB_FONT=/boot/grub2/fonts/DejaVuSansMono.pf2
  1. Regenerate Grub
$ sudo grub-mkconfig -o /boot/grub2/grub.cfg
1 Like

I don’t have the dejavu-sans-mono-fonts folder. This is what I have:

wiking@walhalla:~$ ls /usr/share/fonts/
aajohan-comfortaa-fonts       google-droid-sans-fonts             google-noto-vf          lm-math                    rit-rachana-fonts
abattis-cantarell-fonts       google-noto                         jomolhari-fonts         madan-fonts                sil-mingzat-fonts
abattis-cantarell-vf-fonts    google-noto-color-emoji-fonts       lato-fonts              mathjax                    sil-nuosu-fonts
adobe-source-code-pro-fonts   google-noto-emoji-fonts             liberation-mono-fonts   mnsymbol                   sil-padauk-fonts
gdouros-symbola               google-noto-sans-cjk-vf-fonts       liberation-sans-fonts   open-sans                  stix-fonts
glyphography-newscycle-fonts  google-noto-sans-mono-cjk-vf-fonts  liberation-serif-fonts  paktype-naskh-basic-fonts  urw-base35
gnu-free                      google-noto-serif-cjk-vf-fonts      lm                      rit-meera-new-fonts        vazirmatn-vf-fonts

I was able to build the .pf2 font with this command:

sudo grub2-mkfont -o DejaVuSansMono.pf2 -s 43 /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf

I moved the .pf2 file here:

wiking@walhalla:~$ sudo ls /boot/grub2/fonts/ 
DejaVuSansMono.pf2  unicode.pf2

This is what my /etc/default/grub looks like:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
#GRUB_TERMINAL_OUTPUT="gfxterm"
#GRUB_GFXMODE=1280x720
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-82adf451-f027-4115-9dd7-46575fb4a044 rhgb quiet rd.driver.blacklist=nvidia modprobe.blacklist=nvidia"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_THEME="/boot/grub2/themes/polylight/theme.txt"
GRUB_FONT=/boot/grub2/fonts/DejaVuSansMono.pf2

Are you sure I don’t need quotation marks?

I used this command to make the grub.cfg:

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

Right now, this solution doesn’t work at all. The font looks way too small. I’m not sure what the issue is.

You’re right. The “polylight” theme was setting an 18 point font in several places. I had to disable the theme in /etc/default/grub.

Can you think of a theme that would work with this 43 point font?

Does GRUB2 seem slow and less responsive using the full resolution and 43 point .pf2 font, when doing this compared to just setting these?

GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_GFXMODE=1280x720

I find that using the full resolution graphics and the 43 point .pf2 font looks good, but the cursor seems to move very slow, especially when editing the kernel parameters using ‘E’. So, I switched back to using 1280x720 and at least the cursor is more responsive. At least I can say I tried it your way.