vbe: Add support for user loadable fonts for the menu

This commit is contained in:
mintsuki 2020-12-05 04:42:19 +01:00
parent 34138387a3
commit 8d04ab1c30
7 changed files with 18 additions and 1 deletions

View File

@ -54,6 +54,7 @@ Some keys take *URIs* as values; these are described in the next section.
* `DEFAULT_ENTRY` - 1-based entry index of the entry which will be automatically selected at startup. If unspecified, it is `1`.
* `GRAPHICS` - If set to `yes`, do use graphical VESA framebuffer for the boot menu, else use text mode.
* `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`.
* `MENU_FONT` - URI path to a font file to be used instead of the default one for the menu. The font file must be a consecutive bitmap containing 8x16 glyphs in ASCII.
* `THEME_COLOURS` - Specifies the colour palette used by the terminal (AARRGGBB). It is a `;` separated array of 8 colours: black, red, green, brown, blue, magenta, cyan, and gray, respectively. Ignored if `GRAPHICS` is not `yes`.
* `THEME_COLORS` - Alias of `THEME_COLOURS`.
* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.

View File

@ -52,6 +52,7 @@ echfs-test: all limine-install test.hdd
echfs-utils -m -p0 test.hdd import stage2.map boot/stage2.map
echfs-utils -m -p0 test.hdd import test/test.elf boot/test.elf
echfs-utils -m -p0 test.hdd import test/bg.bmp boot/bg.bmp
echfs-utils -m -p0 test.hdd import test/font.bin boot/font.bin
./limine-install limine.bin test.hdd
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.hdd -debugcon stdio

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,7 @@
#include <lib/print.h>
#include <lib/image.h>
#include <lib/config.h>
#include <lib/uri.h>
#include <mm/pmm.h>
#include <mm/mtrr.h>
@ -380,7 +381,20 @@ bool vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _
mtrr_set_range((uint64_t)(size_t)vbe_framebuffer,
(uint64_t)vbe_pitch * vbe_height, MTRR_MEMORY_TYPE_WC);
vga_font_retrieve();
char *menu_font = config_get_value(NULL, 0, "MENU_FONT");
if (menu_font == NULL) {
vga_font_retrieve();
} else {
struct file_handle f;
if (!uri_open(&f, menu_font)) {
print("menu: Could not open font file.\n");
vga_font_retrieve();
} else {
vga_font = ext_mem_alloc(VGA_FONT_MAX);
fread(&f, vga_font, 0, VGA_FONT_MAX);
}
}
*_cols = cols = (vbe_width - _margin * 2) / VGA_FONT_WIDTH;
*_rows = rows = (vbe_height - _margin * 2) / VGA_FONT_HEIGHT;
grid = ext_mem_alloc(rows * cols * sizeof(struct vbe_char));

View File

@ -2,6 +2,7 @@ DEFAULT_ENTRY=2
TIMEOUT=3
GRAPHICS=yes
MENU_RESOLUTION=1024x768
MENU_FONT=bios://:1/boot/font.bin
E9_OUTPUT=yes
STAGE2_MAP=bios://:1/boot/stage2.map