| Crates.io | bdf2 |
| lib.rs | bdf2 |
| version | 0.7.1 |
| created_at | 2024-12-08 05:39:48.871667+00 |
| updated_at | 2024-12-08 05:39:48.871667+00 |
| description | BDF format handling. |
| homepage | |
| repository | https://github.com/meh/rust-bdf |
| max_upload_size | |
| id | 1476072 |
| size | 303,661 |
BDF font handler
This crate allows you to read and write BDF fonts in Rust.
This example will draw a given glyph in your terminal using the given font.
use std::char;
use std::env;
use std::process::exit;
let font = bdf::open(env::args().nth(1).expect("missing font file")).unwrap();
let codepoint = char::from_u32(
env::args()
.nth(2)
.expect("missing codepoint")
.parse()
.unwrap(),
)
.expect("invalid codepoint");
let glyph = font.glyphs().get(&codepoint).unwrap_or_else(|| exit(1));
for y in 0..glyph.height() {
for x in 0..glyph.width() {
if glyph.get(x, y) {
print!("██");
} else {
print!(" ");
}
}
print!("\n");
}