feat(display): DrawText with built-in Spleen 8x16 font (BSD-2)

This commit is contained in:
2026-10-27 16:33:26 +01:00
parent 8587661684
commit 64ec5df379
8 changed files with 290 additions and 2 deletions

View File

@@ -37,3 +37,16 @@ pub fn get_dimensions(ep: CapSlot) -> (Dimension, Dimension) {
(Dimension::new(0), Dimension::new(0))
}
}
/// Draws `s` (up to `TEXT_BYTES` per call, more in several) from `(x, y)`.
pub fn draw_text(ep: CapSlot, x: ScreenCoord, y: ScreenCoord, fg: Color, bg: Color, s: &[u8]) {
use types::display::text::{TEXT_BYTES, Text};
for (i, chunk) in s.chunks(TEXT_BYTES).enumerate() {
let x = ScreenCoord::new(x.raw().saturating_add((i * TEXT_BYTES * CELL_WIDTH) as u16));
let _ = syscall::request(ep, Text::new(x, y, fg, bg, chunk).words());
}
}
/// The display server's character cell, in pixels.
pub const CELL_WIDTH: usize = 8;
pub const CELL_HEIGHT: usize = 16;