#freetype #font #glyph

ndless-freetype

Bindings for FreeType font library for Ndless

4 releases

0.1.3 Jun 4, 2019
0.1.2 Mar 18, 2019
0.1.1 Feb 10, 2019
0.1.0 Feb 10, 2019

#17 in #freetype

39 downloads per month
Used in ndless-sdl

MIT license

56KB
1.5K SLoC

ndless-freetype

Rust bindings for FreeType library for Ndless


lib.rs:

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;

    // 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, freetype::face::RENDER).unwrap();
    // Get the glyph instance
    let glyph = face.glyph();
    do_something_with_bitmap(glyph.bitmap());
}

See in the examples/ folder for more examples.

External links

Dependencies

~1MB
~21K SLoC