Crate font_loader

Source
Expand description

§Font-Loader

A font loading utility written in and for Rust.

Currently supported platforms:

  • Windows
  • Mac
  • *nix systems

§Usage

§Linux, Unix:

Fontconfig is required on Linux and Unix, as it is the default Fontmanagement utility on these platforms.

sudo apt-get install libfontconfig libfontconfig1-dev

§Example

§Cargo.toml

[dependencies]
font-loader = "https://github.com/matprec/rust-font-loader"

§main.rs:

extern crate font_loader as fonts;

use fonts::system_fonts;

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

Modules§

  • Font loading utilities for installed system fonts