vbe: Add support for user loadable fonts for the menu
diff --git a/CONFIG.md b/CONFIG.md
index f9c5e48b..4f12071a 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -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`.
diff --git a/Makefile b/Makefile
index e5dc26e8..26061861 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/limine-pxe.bin b/limine-pxe.bin
index 9bea5b6f..6f7b527b 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index d59d1e9a..c9ea74c2 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2.map b/stage2.map
index e735979d..6405917a 100644
Binary files a/stage2.map and b/stage2.map differ
diff --git a/stage2/drivers/vbe.c b/stage2/drivers/vbe.c
index beeabb27..94d6003b 100644
--- a/stage2/drivers/vbe.c
+++ b/stage2/drivers/vbe.c
@@ -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));
diff --git a/test/limine.cfg b/test/limine.cfg
index 6581d109..c6c3fd17 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -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
