font_loader::system_fonts

Function get

Source
pub fn get(config: &FontProperty) -> Option<(Vec<u8>, c_int)>
Expand description

Get the binary data and index of a specific font Note that only truetype fonts are supported

Examples found in repository?
examples/list-fonts.rs (line 37)
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
fn main() {
	// Enumerate all fonts
    let sysfonts = system_fonts::query_all();
    for string in &sysfonts {
        println!("{}", string);
    }

	let mut property = system_fonts::FontPropertyBuilder::new().monospace().build();
	let sysfonts = system_fonts::query_specific(&mut property);
	for string in &sysfonts {
		println!("Monospaced font: {}", string);
	}

	let property = system_fonts::FontPropertyBuilder::new().family("Arial").build();
	let (font, _) = system_fonts::get(&property).unwrap();
	println!("{:?}", &font[..50]);
}