simple-psf

Crates.iosimple-psf
lib.rssimple-psf
version0.1.2
sourcesrc
created_at2024-05-19 21:58:54.657682
updated_at2024-05-20 04:57:25.90395
descriptionA simple library for parsing PSF bitmap font files.
homepage
repositoryhttps://github.com/Jayshua/simple-psf
max_upload_size
id1245238
size9,585
(Jayshua)

documentation

README

A simple parser for the PC Screen Font file format used to store bitmap fonts, most notably for use in the Linux kernel's built-in console.

Cozette is a good sample PSF font if you're looking for one.

This crate is no_std, no_alloc, and should never panic.

Example

let data: &[u8] = &std::fs::read("cozette.psf").unwrap();
let psf = simple_psf::Psf::parse(data).unwrap();

for glyph_index in b'a' as usize ..= b'z' as usize {
	for (index, pixel_on) in psf.get_glyph_pixels(glyph_index).unwrap().enumerate() {
		if index % psf.glyph_width == 0 {
			println!("");
		}

		if pixel_on {
			print!("@");
		} else {
			print!(" ");
		}
	}
}

Commit count: 4

cargo fmt