Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add TextBuffer #452

Open
bingmatv opened this issue Aug 13, 2024 · 5 comments
Open

add TextBuffer #452

bingmatv opened this issue Aug 13, 2024 · 5 comments

Comments

@bingmatv
Copy link

There's FrameBuffer but no TextBuffer.

@bjorn3
Copy link
Contributor

bjorn3 commented Aug 13, 2024

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.

@bingmatv
Copy link
Author

(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.

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 10, 2024

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.

@bingmatv
Copy link
Author

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

Why vectors and floats lead to kernel exploits?

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants