fschutt / rust-fontconfig

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

Fix the query logic for `italic`, `oblique`, `bold`, and `monospace`. #10

Closed zedseven closed 7 months ago

zedseven commented 7 months ago

I noticed that the query logic seemed to be broken for italic, oblique, bold, and monospace.

The below code yielded no results, even though I could see a matching font in the list:

cache.query(&FcPattern {
    family: Some(String::from("Dank Mono")),
    bold: PatternMatch::False,
    italic: PatternMatch::False,
    ..Default::default()
})

The font in the list that it should match:

FcPattern {
    name: Some(
        "Dank Mono Regular",
    ),
    family: Some(
        "Dank Mono",
    ),
    italic: False,
    oblique: DontCare,
    bold: False,
    monospace: DontCare,
    condensed: DontCare,
    weight: 0,
    unicode_range: [
        0,
        0,
    ],
}

If I've missed something that the old logic was supposed to cover, please let me know.