Crates.io | bdf |
lib.rs | bdf |
version | 0.6.0 |
source | src |
created_at | 2015-07-16 17:17:59.664406 |
updated_at | 2020-07-20 21:26:20.43893 |
description | BDF format handling. |
homepage | |
repository | https://github.com/meh/rust-bdf |
max_upload_size | |
id | 2615 |
size | 250,207 |
BDF handling library.
[dependencies]
bdf = "*"
This example will draw a given glyph in the given font.
extern crate bdf;
use std::env;
use std::process::exit;
use std::char;
fn main() {
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");
}
}