Crate fontconfig

Source
Expand description

A wrapper around [freedesktop.org’s fontconfig library][homepage], for locating fonts on a UNIX like systems such as Linux and FreeBSD. Requires fontconfig to be installed.

See the fontconfig developer reference for more information.

§Dependencies

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

§Usage

Cargo.toml:

[dependencies]
fontconfig = "0.1.0"

main.rs:

use fontconfig::{Font, 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());
}

Structs§

  • A very high-level view of a font, only concerned with the name and its file location.
  • Wrapper around FcFontSet.
  • Handle obtained after Fontconfig has been initialised.
  • Wrapper around FcObjectSet.
  • A safe wrapper around fontconfig’s FcPattern.
  • Error type returned from Pattern::format.

Enums§

  • The format of a font matched by Fontconfig.

Constants§

Functions§

  • Return a FontSet containing Fonts that match the supplied pattern and objects.