From 540f288e61387297e297fab25b991bbf5afbd38d Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Tue, 11 Jul 2017 20:23:33 +0100 Subject: [PATCH] Select appropriate font for console devices with font support The hal package automatically selects the best font from the list of available fonts based on the console dimensions and the font priorities. The font selection can be overriden by passing the "consoleFont" boot commandline parameter to the kernel (e.g. consoleFont=terminus8x16) --- src/gopheros/kernel/hal/hal.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gopheros/kernel/hal/hal.go b/src/gopheros/kernel/hal/hal.go index ff91e05..b23b517 100644 --- a/src/gopheros/kernel/hal/hal.go +++ b/src/gopheros/kernel/hal/hal.go @@ -5,6 +5,8 @@ import ( "gopheros/device" "gopheros/device/tty" "gopheros/device/video/console" + "gopheros/device/video/console/font" + "gopheros/kernel/hal/multiboot" "gopheros/kernel/kfmt" ) @@ -30,6 +32,28 @@ func DetectHardware() { consoles := probe(console.ProbeFuncs) if len(consoles) != 0 { devices.activeConsole = consoles[0].(console.Device) + + if fontSetter, ok := (devices.activeConsole).(console.FontSetter); ok { + consW, consH := devices.activeConsole.Dimensions(console.Pixels) + + // Check boot cmdline for a font request + var selFont *font.Font + for k, v := range multiboot.GetBootCmdLine() { + if k != "consoleFont" { + continue + } + + if selFont = font.FindByName(v); selFont != nil { + break + } + } + + if selFont == nil { + selFont = font.BestFit(consW, consH) + } + + fontSetter.SetFont(selFont) + } } ttys := probe(tty.ProbeFuncs)