grub-tweaks icon indicating copy to clipboard operation
grub-tweaks copied to clipboard

How use grub font generated by grub-mkfont inb your own theme?

Open hugo-is-hugo opened this issue 1 year ago • 2 comments

I have issue to load the pf2 font I have created using grub-mkfont

I tried to follow your steps here to create it: Creating custom fonts (.pf2) for GRUB] (https://github.com/VandalByte/grub-tweaks#-topics)

I run this command: sudo grub-mkfont --output=./DejaVuSansMono28.pf2 --size=28 /usr/share/fonts/TTF/dejavu/DejaVuSansMono.ttf

on a font that is local already on Ubuntu 24.04 (To make it easy to reproduce and we might use same font).

But when loading it in theme.txt like this. I only see the color take effect, but the theme font is not loaded (I use grub2-theme-preview look it there I see on command line they are loaded. However not in GUI)

+ boot_menu {
    ....
    item_font = "DejaVuSansMono20.pf2"
    item_color = "#919090"
    selected_item_font = "DejaVuSansMono30.pf2""
    selected_item_color = "#ffffff"
    ...
}

I saw that you loaded your font like this: item_font = "Norwester Regular 28"

in https://github.com/VandalByte/dedsec-grub2-theme

but the files in the dedsec had format:

norwester_24.pf2
norwester_28.pf2
norwester_30.pf2

How do you know what name to use in item_font? How do you create it in the font?

hugo-is-hugo avatar May 11 '24 11:05 hugo-is-hugo

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

The bold font name in the output is the name that I needed to use in theme.txt for the fonts.

+ boot_menu {
    ....
    item_font = "DejaVu Sans Regular 30"

Maybe the guide could clarify this step? Also thanks for a very good guide. Hope more start to create themes since very few nice theme beside yours.

hugo-is-hugo avatar May 12 '24 09:05 hugo-is-hugo

@hugo-is-hugo

Yeah so the file name has nothing to do with how grub sees the font file, what I usually did was, just put all the fonts that I wanted to test and list all that loaded fonts in grub command line, didn't knew about the verbose tho

If possible, add it to this section and submit a pull request so that others facing the same issue can easily find it or I'll try to add it when I get some free time. Cheers! https://github.com/VandalByte/grub-tweaks#%EF%B8%8F-creating-custom-fonts-pf2-for-grub

VandalByte avatar May 16 '24 20:05 VandalByte