Crate freetype

source ·
Expand description

Rust wrapper around freetype 2 library

Initialization

To create a new freetype context, instantiate the Library struct as below. The Library (along with other objects) obeys RAII and is dropped when the struct goes out of scope.

Example

extern crate freetype;

fn main() {
    use freetype::Library;
    use freetype::face::LoadFlag;

    // Init the library
    let lib = Library::init().unwrap();
    // Load a font face
    let face = lib.new_face("/path/to/a/font/file.ttf", 0).unwrap();
    // Set the font size
    face.set_char_size(40 * 64, 0, 50, 0).unwrap();
    // Load a character
    face.load_char('A' as usize, LoadFlag::RENDER).unwrap();
    // Get the glyph instance
    let glyph = face.glyph();
    do_something_with_bitmap(glyph.bitmap());
}

See in the examples/ folder for more examples.

Re-exports

Modules

Type Definitions