fontconfig-rs
fontconfig-rs copied to clipboard
improve the Pattern::add_string ergonomics
I feel it would be nice to hide the CStr's from the API here:
pub fn add_string(&mut self, name: &CStr, val: &CStr)
and have a type for the different kinds of key values, which could then be safely converted internally to an FcPattern.
I am imagining a safe type something like
pub enum PatternKeyValue =
Family: &str,
Style: &str,
:
Lang: &str,
Charset: u32,
:
Variable: bool;
:
Any thoughts?
Sounds reasonable. Like a more general version of find, which takes care of the c strings if you're only matching on family and style:
https://github.com/yeslogic/fontconfig-rs/blob/da4c674a2a5b5a04099bd1a9312e090b13865bd1/fontconfig/src/lib.rs#L142