No box characters after changing the default Grub font

26,881

Solution 1

In theory grub-mkfont allows passing multiple fonts. In this case if you can pass a link to Unifont or another font with wider coverage at the same time. The produced Grub font will be a combination of the coverage of both input fonts.

Note: a recent performance improvement to the Grub boot-time font loader means that the glyphs in a Grub font file must be in a specific ascending order, but unfortunately the change was not made to the grub-mkfont utility at the same time! This is now a bug:

  • Bug #729470 "grub-mkfont outputs fonts that grub cannot use (font characters not in ascending order: 0 <= 0)"

BTW, if you're interested, this bug was discovered because of experiments with investigating use of the Ubuntu Font Family in-development Ubuntu Mono font in the Grub boot menus and hitting exactly the same problem that you've just hit!

Solution 2

Basically what you want to do is use the range operator to limit the characters that your new grub font contains. If you don't use the range operator then you're going to get all the glyphs including the erroneous or incorrect box elements from your target font.

For example:

grub-mkfont -s 16 --range=0x0-0x7f -o /boot/grub/grubfont.pf2 font.tty

Will generate a font with only ASCII characters, anything your font doesn't have should decay gracefully to the default font so boxes and arrows should come from the default. Please see this website for further information:

http://web.archive.org/web/20100429235139/http://grub.enbug.org/gfxterm

Solution 3

IIRC I ran into what you describe when using all glyphs:


(source: xrmb2.net)

Maybe it's an issue with grub-mkfont, maybe it has to do with the font, I don't know. :(

What worked for me:

  1. Using gbdfed to generate the 'bdf' file from a console font (eg. '/usr/share/consolefonts/Lat15-VGA16.psf'): File > Import > Console Font, then File > Save As...
  2. Converting only the ASCII characters with grub-mkfont:

    grub-mkfont --output=out.pf2 --range=0x0-0x7f out.bdf

Solution 4

If you run grub-mkfont with the -v flag it will show you how many glyphs you get. If you get more than a thousand, the border character ought to be in there. Limiting the range will only make things worse. The DejaVuSansMono font displays all the characters correctly and it has over 3000 glyphs in the .pf2. Many other fonts get the arrows right but not the border.

Solution 5

use a unicode font.. That worked almost fine( such as arialuni.ttf, shows all characters as required).. My problem is with the little bigger character spacing...and that happens with every font I tested.

Share:
26,881

Related videos on Youtube

KindDragon
Author by

KindDragon

Updated on September 17, 2022

Comments

  • KindDragon
    KindDragon over 1 year

    I've been able to change the default font of Grub, by using

    grub-mkfont -s 16 -o /boot/grub/grubfont.pf2 font.tty
    

    and then adding the following line to /etc/default/grub:

    GRUB_FONT=/boot/grub/grubfont.pf2
    

    And of course

    sudo update-grub
    

    And the new font did show up and everything (remember to chose a monospaced font). But, the "box" characters (around the entries) are never displayed correctly. I guess most fonts simply don't have that character set. Is there any way that I can add these characters? Maybe even copy them from the default unicode.pf2 font? If this is not really possible, do you know of any fonts that have got these characters?

    Update:

    I have tried a lot of different things, such as converting from ttf to bdf and then to pf2, and I have tried converting only the ascii characters with the option --range=0x0-0x7f, but none of them seemed to make it work perfectly. I have a feeling that it is because I'm generating a larger font than the default, and the default glyphs therefore cannot be used.

    I will try to see if I can get it to work with a smaller font size, though this were one of the reasons I wanted to change the font.

    • Extender
      Extender over 13 years
      Try BURG its very nice and has a lot of themes
    • WindowsEscapist
      WindowsEscapist over 11 years
      But OP wants to change font - not theme GRUB. Irrelevant.
  • KindDragon
    KindDragon over 13 years
    It seems that my main problem is that I want to use an OpenType font (ttf), and not a font designed for consoles. I've tried the above with a ttf file, but it didn't help on this particular problem. Thanks a lot for a solution to a similar problem though :).
  • KindDragon
    KindDragon over 13 years
    That would make sense, but I'm still having the weird glyphs, maybe because the unicode font isn't loaded at all? I will try to set the default font back, and the try this again.
  • Martin Owens -doctormo-
    Martin Owens -doctormo- over 13 years
    Perhaps you should load a console font first and then load your ttf ascii only font.
  • Martin Owens -doctormo-
    Martin Owens -doctormo- over 13 years
    Have you tried loading multiple fonts? the unicode font /usr/share/grub/unicode.pf2 should contain the box and arrow characters you need. You should be able to load the fonts using loadfont one after another until you get the desired effect.
  • KindDragon
    KindDragon almost 13 years
    I will let it rest till they get the Ubuntu Mono font loaded into grub - that's what I was after in the first place anyway :) Thanks a lot.