wiking5
(Wiking)
December 13, 2024, 4:15pm
1
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/
litemotiv
(Olivier)
December 13, 2024, 6:43pm
3
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.
Copy the font to /boot/grub2/fonts/DejaVuSansMono.pf2
Then add the font to /etc/default/grub
:
GRUB_FONT=/boot/grub2/fonts/DejaVuSansMono.pf2
Regenerate Grub
$ sudo grub-mkconfig -o /boot/grub2/grub.cfg
1 Like
wiking5
(Wiking)
December 14, 2024, 3:59pm
4
steppybug:
I am no font expert.
grub2-mkfont -o DejaVuSansMono.pf2 -s 43 /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf
made a font that works in grub. The file size is much smaller than the default /boot/grub/fonts/unicode.pf2 font. But grub text was large!
The DejaVu font sources are available so I imagine a lot better result could be obtained using FontForge .
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
wiking5
(Wiking)
December 14, 2024, 7:07pm
6
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.
wiking5
(Wiking)
December 14, 2024, 9:33pm
8
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?
wiking5
(Wiking)
December 17, 2024, 2:23am
10
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.