mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
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)
This commit is contained in:
parent
d71c4c1eea
commit
540f288e61
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user