yeslogic / fontconfig-rs

Safe wrapper around freedesktop.org's fontconfig library, for locating fonts on UNIX like systems.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

improve the Pattern::add_string ergonomics

juhp opened this issue · comments

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:

fn find(fc: &Fontconfig, family: &str, style: Option<&str>) -> Option<Font> {