rust-font-loader icon indicating copy to clipboard operation
rust-font-loader copied to clipboard

Cannot load generic font family on MacOS

Open 38 opened this issue 4 years ago • 2 comments

Hi,

Thanks for the great crate, I used this to load system fonts for my crate Plotters. Recently we've added a feature that supports generic font families like serif, serif-sans and monospace.

On Linux, query a generic font family will return expected result. But On MacOS, it seems font-loader doesn't have a way to load generic font family and querying "serif" will directly return FontNotFound.

I believe CTFontStylisticClass should be one way to query the generic font class.

Also there's a behavior difference on MacOS and Linux when font is not found. On Linux it returns the default font, on MacOS it returns an error.

Could you please give some guidance on this stuff ?

Thanks!


Update, just tried windows it seems it constantly return arial font if the requested font is not exists. Including requesting the general font families

38 avatar Oct 25 '19 15:10 38

I can't really comment on the MacOS implementation, i don't own a mac device / don't have access. If you time to spare, feel free to do so :)

IIRC some servo engineers provided the original implementation. They since wrote their own implementation, called font-kit. You should check if it suits your needs!

matprec avatar Oct 26 '19 12:10 matprec

Yep, that works correctly on all platforms. But you know I still kind of like this crate because it has way less dependency. (Also for rusttype).

Thanks for the information!

38 avatar Oct 27 '19 16:10 38