3 unstable releases
0.2.0 | Jan 6, 2024 |
---|---|
0.1.1 | Dec 17, 2023 |
0.1.0 | Dec 16, 2023 |
#189 in No standard library
16KB
148 lines
fleck — a library for using uf2 fonts
uf2 is a bitmap font format used in the uxn ecosystem for personal computing. This is a small, simple library for parsing and using uf2 fonts in rust projects.
Some choices and a demo in this library were informed by the structure of the
wonderful psf2
crate.
Also, if no_std
is your cup of tea, you can use the no_std
feature flag to ensure all functionality is no_std
and no_alloc
.
fleck is part of the broader weft ecosystem.
If you enjoy fonts like uf2, you may like tid and other things in the weft project as well! This project originates from the uf2 parser for tid.
examples
let mut data = [0u8; fleck::FILE_SIZE];
let mut file = std::fs::File::open(file_path).expect("could not find font file");
file.read_exact(&mut data).expect("could not read font data");
let font = Font::new(&data);
// Alternatively you could use `Font::load_from_file(file_path)`
// if you're fine with using std.
let text = args.next().unwrap_or("demo".to_string());
for ch in message.chars() {
let Some(glyph) = font.glyph(ch) else {
eprintln!("unsupported glyph: {}", ch);
continue;
};
// Print a representation of each glyph to the terminal.
for row in glyph {
for filled in row {
let pixel = if filled { "##" } else { " " };
print!("{pixel}");
}
println!();
}
}
contributing
The issue tracker for fleck can be found at todo.sr.ht/~ma3ke/fleck. We use todo.sr.ht/~ma3ke/weft to keep track of ideas and tasks that pertain to the project as a whole.
NOTE: If you would like to submit changes, but feel intimidated by doing it by email, that is no problem at all! Another fine way is to fork the repository elsewhere, push your changes to there, and send me the link to the commit you want me to consider. Or, just get in touch with a DM or email :)
Patches can be submitted to the weft
mailing list (~ma3ke/weft@lists.sr.ht
).
Before submitting a patch, it is wise and fun to reach out through DM or on the email list for help and discussion.
When submitting a patch via email, please set the subject prefix to [PATCH fleck]
.
git config format.subjectPrefix "PATCH fleck"
(If you don't know how this stuff works, but want to learn about this, git-send-email.io is a fantastic hands-on resource.)
Made with <3 ma3ke