servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
693 stars 104 forks source link

Fallback list in select_best_match #62

Open RazrFalcon opened 5 years ago

RazrFalcon commented 5 years ago

Currently, fonts for sans/serif/monospace/fantasy/etc. are hardcoded for Win and Mac. And there are only one font for each type.

The problem is that it doesn't guarantee that this font is present. For example, a default Win10 contains the Impact font, but the one used by TravisCI - doesn't.

Here is the list of font families available in a Travis instance:

Not sure with one we can use as fantasy. Maybe Ink Free?

pcwalton commented 5 years ago

What a mess. Maybe we should just have a series of fonts to try in order.

pcwalton commented 5 years ago

Oh, I think that's what you were suggesting. Honestly if Impact isn't available, maybe we should just fall back to Arial or something.

RazrFalcon commented 5 years ago

I'm not sure what is an expected behavior in general. All I can find is this: https://www.w3.org/Style/Examples/007/fonts.en.html

So we can just hardcode a list of fonts for each style and check them all before returning NotFound. At least on Windows and macOS. Linux/fontconfig already supports CSS-style font names.

Or simple ignore this issue, since there are no obvious solution.

atouchet commented 1 year ago

Travis CI is no longer being used. Is this issue still relevant?