Crate fontconfig
source · [−]Expand description
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. Alternatively,
set the environment variable RUST_FONTCONFIG_DLOPEN=on
or enable the dlopen
Cargo feature
to load the library at runtime rather than link at build time (useful for cross compiling).
See the Fontconfig developer reference for more information.
Dependencies
- Arch Linux:
fontconfig
- Debian-based systems:
libfontconfig1-dev
- FreeBSD:
fontconfig
- Void Linux:
fontconfig-devel
Usage
use fontconfig::FontConfig;
let mut config = FontConfig::default();
// `FontConfig::find()` returns `Option` (will rarely be `None` but still could be)
let font = config.find("freeserif".to_string(), None).unwrap();
// `name` is a `String`, `path` is a `Path`
println!("Name: {}\nPath: {}", font.name, font.path.display());
Cargo Features
Feature | Description | Default Enabled | Extra Dependencies |
---|---|---|---|
dlopen | dlopen 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.
Re-exports
pub use fontconfig_sys as sys;
pub use blanks::Blanks;
pub use charset::CharSet;
pub use charset::OwnedCharSet;
pub use fontset::FontSet;
pub use langset::LangSet;
pub use langset::LangSetCmp;
pub use matrix::Matrix;
pub use objectset::ObjectSet;
pub use pattern::properties;
pub use pattern::properties::Property;
pub use pattern::properties::PropertyType;
pub use pattern::OwnedPattern;
pub use pattern::Pattern;
pub use strings::FcStr;
pub use stringset::StringSet;
Modules
Wrapper for deprecated sys::FcBlanks
To help applications deal with these UTF-8 strings in a locale-insensitive manner.
Structs
A very high-level view of a font, only concerned with the name and its file location.
Handle obtained after Fontconfig has been initialised.
library version number
Enums
Constants
Functions
Returns the version number of the library.