3 unstable releases

Uses old Rust 2015

new 0.2.1 May 4, 2021
0.2.0 Jun 11, 2020
0.0.1 Dec 11, 2014

#102 in Text processing

Download history 177/week @ 2021-01-15 92/week @ 2021-01-22 158/week @ 2021-01-29 202/week @ 2021-02-05 227/week @ 2021-02-12 165/week @ 2021-02-19 162/week @ 2021-02-26 145/week @ 2021-03-05 132/week @ 2021-03-12 122/week @ 2021-03-19 60/week @ 2021-03-26 114/week @ 2021-04-02 104/week @ 2021-04-09 120/week @ 2021-04-16 102/week @ 2021-04-23 160/week @ 2021-04-30

579 downloads per month
Used in canrust

MIT license

41KB
889 lines

fontconfig-rs


A wrapper around freedesktop.org's Fontconfig library, for locating fonts on a UNIX like systems such as Linux and FreeBSD. Requires Fontconfig to be installed.

Dependencies

  • Arch Linux: fontconfig
  • Debian-based systems: libfontconfig1-dev
  • FreeBSD: fontconfig
  • Void Linux: fontconfig-devel

Usage

main.rs:

use fontconfig::Fontconfig;

fn main() {
    let fc = Fontconfig::new().unwrap();
    // `Fontconfig::find()` returns `Option` (will rarely be `None` but still could be)
    let font = fc.find("freeserif", None).unwrap();
    // `name` is a `String`, `path` is a `Path`
    println!("Name: {}\nPath: {}", font.name, font.path.display());
}

You could then, for example, use font.path to create a GlyphCache from opengl_graphics and pass it to conrod.

Other Fontconfig Crates

  • servo-fontconfig — This crate provides a low-level interface only. It depends on servo-fontconfig-sys, which will fall back to building a vendored version of Fontconfig if a compatible version can't be found. It in-turn depends on expat-sys, which does the same thing regarding a vendored version of Expat. This makes it easier if you are distributing a code base that needs Fontconfig, but provides less control over the libraries that will be used.
  • fontconfig-sys — superceded by yeslogic-fontconfig-sys.
  • yeslogic-fontconfig — This crate was previously published under this name before we were given to publish it as fontconfig.

For our needs in Prince we wanted higher-level bindings that did not fall back on vendored versions of libraries, which is what the crates in this repo provide.

Credits

Thanks to Austin Bonander for originally creating the fontconfig crate and allowing us to publish ours under that name.

Dependencies

~11KB