fschutt / rust-fontconfig

Pure-Rust rewrite of the Linux fontconfig library (no system dependencies) - using ttf-parser and allsorts
MIT License
40 stars 8 forks source link

Monospace search doesn't work #6

Open l4l opened 2 years ago

l4l commented 2 years ago

The following code fails at the second assertion:

let cache = FcFontCache::build();

assert!(cache
    .query(&FcPattern {
        name: Some("DejaVu Sans Mono".into()),
        ..Default::default()
    })
    .is_none());

assert!(cache
    .query(&FcPattern {
        monospace: PatternMatch::True,
        ..Default::default()
    })
    .is_some());

Is it an expected behavior?

Also seems the issue related to #3

fschutt commented 2 years ago

It's not expected behaviour, but then again, this entire library is ~400 lines of code, so it's not really advanced. The feature detection isn't very good. I should not have used "fontconfig" in the title, people now think it's a 1:1 replacement for fontconfig, while it's more or less just one single file.

Maybe use font-kit or fontdb instead for now.

l4l commented 2 years ago

Quiet funny that fontdb also fails for the same query. And font-kit is overkill for me, my case is to find a font by its name or otherwise provide a reasonable default (i.e. any monospace). And I never used fontconfig, tbh.

I guess I could look into the sources then, you're open to patches like this, right?

Also, fontsearch/font-search seems unused at crates.io, maybe switch to one of these instead?

fschutt commented 8 months ago

Maybe try again with 1.0.7, some font search issues have been fixed