Home

Awesome

fontconfig

<div align="center"> <a href="https://github.com/yeslogic/fontconfig-rs/actions/workflows/ci.yml"> <img src="https://github.com/yeslogic/fontconfig-rs/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a> <a href="https://docs.rs/fontconfig"> <img src="https://docs.rs/fontconfig/badge.svg" alt="Documentation"></a> <a href="https://crates.io/crates/fontconfig"> <img src="https://img.shields.io/crates/v/fontconfig.svg" alt="Version"></a> <a href="https://github.com/yeslogic/fontconfig-rs/blob/master/LICENSE"> <img src="https://img.shields.io/crates/l/fontconfig.svg" alt="License"></a> </div> <br>

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

Dependencies

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.

Cargo Features

FeatureDescriptionDefault EnabledExtra Dependencies
dlopendlopen libfontconfig at runtime

The dlopen feature enables building this crate without dynamically linking to the Fontconfig C library at link time. Instead, Fontconfig will be dynamically loaded at runtime with the dlopen function. This can be useful in cross-compiling situations as you don't need to have a version of Fontcofig available for the target platform available at compile time.

Other Fontconfig Crates

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.