Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve the Pattern::add_string ergonomics #31

Open
juhp opened this issue Nov 19, 2022 · 1 comment
Open

improve the Pattern::add_string ergonomics #31

juhp opened this issue Nov 19, 2022 · 1 comment

Comments

@juhp
Copy link

juhp commented Nov 19, 2022

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?

@wezm
Copy link
Contributor

wezm commented Nov 22, 2022

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> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants