bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

add TextBuffer

Open bingmatv opened this issue 1 year ago • 5 comments

There's FrameBuffer but no TextBuffer.

bingmatv avatar Aug 13 '24 12:08 bingmatv

If you boot using BIOS, you can use VGA text mode to directly feed text to the GPU. Bowever in the case of UEFI, GOP (the UEFI replacement for the VGA and VESA device interfaces) only supports setting up framebuffers. Because of this the kernel has to turn text into pixels itself. For consistency the bootloader crate only provides a framebuffer interface, even on BIOS where it could technically provide a text mode interface.

bjorn3 avatar Aug 13 '24 13:08 bjorn3

(the UEFI replacement for the VGA and VESA device interfaces) only supports setting up framebuffers

How to load and parse existing fonts developed by people? E.g, to copy the fonts from Host OS.

ghost avatar Nov 10 '24 07:11 ghost

Parsing and rendering of regular vector fonts is very complex (and slow inside a kernel due to needing to use soft floats there) and almost certainly not what you want in the kernel. (it has lead to countless of kernel exploits in the case of windows for example) Rather you likely want to use a pre-rasterized font instead. There are several crates that contain pre-rasterized fonts like noto_sans_mono_bitmap (containing Noto Sans Mono) Or you can use the mono_font module of the embedded-graphics crate.

bjorn3 avatar Nov 10 '24 09:11 bjorn3

lead to countless of kernel exploits in the case of windows for example

Why vectors and floats lead to kernel exploits?

ghost avatar Nov 10 '24 11:11 ghost

There are two separate big problems with rendering vector fonts in the kernel:

  • It is slow. This is because vector font rendering depends on floats and inside a kernel you generally can't use the hardware float support and are forced to use the much slower software implementation of floats (softfloat) instead.
  • It is insecure. The common font formats are really complex and even contain several languages that are complex enough to have a pokemon clone programmed entirely in it (https://www.coderelay.io/fontemon.html) or, with HarfBuzz's new wasm shaper, run an actual LLM inside the font (https://fuglede.github.io/llama.ttf/). For web fonts, web browsers do a significant amount of work to sanitize potentially malicious fonts.

These two problems are entirely separate, but both are reasons you don't want to process vector fonts inside the kernel and should rather use a pre-rasterized bitmap font instead.

bjorn3 avatar Nov 10 '24 12:11 bjorn3