Skip to main content

Crate bdf2

Crate bdf2 

Source
Expand description

BDF font handler

This crate allows you to read and write BDF fonts in Rust.

§Example

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");
}

Structs§

Bitmap
The bitmap of a glyph.
BoundingBox
The bounds of a glyph.
Font
A BDF font.
Glyph
A font glyph.
Reader
The font reader.
Size
Size of a font.
Writer
The font writer.

Enums§

Direction
The direction of the glyph.
Entry
The possible entries in BDF.
Error
Errors for Reader and Writer.
Property
A Font property.

Functions§

open
Open a BDF file and read it into a Font.
read
Read a BDF stream into a Font.
save
Save the font into a BDF file.
write
Write the font to the writer.