gfxterm

gfxterm is a graphical output terminal for GRUB 2. It is being constantly improved and therefore this page will be in flux. This page contains information how to use the module.

gfxterm uses GRUB 2's VideoSubsystem to draw graphics to the screen. This allows the same terminal output code to be used on all graphics adapters where there is a video driver. Currently there is only one, and that uses VESA BIOS Extensions 2.0+ support, present on most current graphics adapters on the x86 platform.

In order to support international characters, there is a font system built for GRUB 2 and gfxterm uses it. Currently only loaded fonts in one custom font-file format are supported.

Configuring VideoSubsystem

VideoSubsystem is a graphics driver architecture for GRUB 2. It supports all commonly used graphical operations to draw onto the screen. VideoSubsystem consists of a core module (video.mod), plus graphics-adapter drivers. You can load multiple drivers at the same time, but only one of them are used at a time. When a driver reports that a graphical mode has successfully initialized, that driver will be selected as active.

Example for loading the VESA BIOS Extension 2.0+ Driver (vbe.mod):

insmod video
insmod vbe

Configuring the font system

If you want text to be displayed under gfxterm, there must be at least one font loaded. The most important set of glyphs that must be present in any font chosen is the set of ASCII characters, since most GRUB 2 messages are encoded in ASCII. The set covering all normally used glyphs includes Latin-1, Latin Extended A+B, Arrows, Box and Block characters. As GRUB 2 uses Unicode internally, all glyphs in fonts must also use standard Unicode codes. Currently only monochrome bitmap fonts are supported.

To get started, you can use GNU Unifont (unifont.pcf.gz). This font file is included in xfonts-unifont in Debian and Ubuntu. The default location for unifont.pcf.gz in this package is /usr/share/fonts/X11/misc/unifont.pcf.gz. GRUB 2's configure script automatically tries to detect and automatically convert fonts from that file if present.

To compile grub-mkfont you need to have libfreetype and to invoke ./configure with --enable-grub-mkfont

If you want to convert fonts manually you can do so by invoking the font converter from the command line:

grub-mkfont --output=<target PF2 file> --range=[[range in hex], ..] <source font file>

grub-mkfont supports every font format that libfreetype supports, like PCF,BDF and TTF. The bitmap font formats like PCF and BDF are recommended over outline fonts like TTF.

Example for converting all glyphs from unifont.pcf.gz to pf2 format:

grub-mkfont --output=unifont.pf2 unifont.pcf.gz

Example for converting only ASCII characters:

grub-mkfont --output=ascii.pf2 --range=0x0-0x7f unifont.pcf.gz

Example for converting Latin-1, Latin Extended A+B, Arrows, Box and Block characters:

grub-mkfont --output=unifont.pf2 --range=0x0000-0x0241,0x2190-0x21FF,0x2500-0x259f unifont.pcf.gz

Example for converting Arabic characters (Please note that displaying Arabic doesn't work as expected at this time)

grub-mkfont --output=unifont.pf2 --range=0x600-0x6ff,0x750-0x77f,0xfb50-0xfdff,0xfe70-0xfeff unifont.pcf.gz

Example for converting Arabic characters with Latin-1, Latin "to have Arabic with English support"

grub-mkfont --output=unifont.pf2 --range=0x600-0x6ff,0x750-0x77f,0xfb50-0xfdff,0xfe70-0xfeff,0x0000-0x0241,0x2190-0x21FF,0x2500-0x259f unifont.pcf.gz

And now that you have fonts converted you can load them from GRUB 2. First, you must load the font module and then use the loadfont command to load the actual font.

Example for loading a font:

insmod font
loadfont /boot/grub/unifont.pf2

Configuring gfxterm

gfxterm uses GRUB 2's environment variables for configuration. Currently there is only one used variable, gfxmode, which controls the resolution that will be chosen when the output terminal is initialized. gfxterm offers this resolution information to all drivers registered in the VideoSubsystem and picks the first one that accepts the mode. If the specified mode is not supported by any graphics driver, terminal initialization will fail and the previous terminal driver will be re-initialized (this feature is still in the oven :)).

gfxmode is formatted in form <width>x<height>[x<depth>][;<another mode>], where color bitdepth can be omitted. If multiple modes are provided, each mode is tried in order. The first mode to be successfully initialized by a graphics driver will be used. Please note that gfxmode only applies to the gfxterm module. It will not affect the mode set for booting the OS. To initialize the graphical terminal, enter the command "terminal_output gfxterm". Make sure you have loaded the font before entering graphics mode, or you will only see blocky characters.

Note: You can only use modes supported by the selected video driver. For the VESA BIOS Extensions 2.0+ driver, you can list supported modes for your video adapter by issuing the vbeinfo command ("insmod vbeinfo"). The following Wiki page also describes some commonly-found video modes: http://en.wikipedia.org/wiki/VESA_BIOS_Extensions#Modes_defined_by_VESA.

Example:

insmod gfxterm
set gfxmode=1024x768x32
terminal_output gfxterm

Here's an example that includes a preference for full-color (32-bit) modes and then, as a fall-back, tries to use modes in any color depth:

insmod gfxterm
set gfxmode="1024x768x32,800x600x32,640x480x32,1024x768,800x600,640x480"
terminal_output gfxterm

This currently does not work for me. You must run vbeinfo before gfxterm, otherwise gfxterm fails.

To get back to text console, use following:

terminal_output console


GrubWiki: gfxterm (last edited 2010-01-28 19:51:52 by FelixZielcke)