alerque / libertinus

The Libertinus font family
Other
957 stars 57 forks source link

Design style for Libertinus Mono not set to Monospaced on macOS? #411

Open somelinguist opened 3 years ago

somelinguist commented 3 years ago

In Font Book on macOS, there is Smart Collection that lists all installed fonts that have the Design style set to Monospaced.

Though I have installed Libertinus Mono on my Mac, but it isn't listed as Fixed Width font in Font Book, and it isn't available as an option in other apps that list only monospaced fonts.

Libertinus Mono installed in Font Book Libertinus Mono not listed in Fixed Width Smart Collection

Font version: 7.020 OS version: macOS Big Sur 11.1

alerque commented 3 years ago

This is an absolutely spectacular can of worms. As far as I can find online Font Book appears to be doing two things –both of them wrong– to make this "design style" list. First it's looking for fonts that have the isFixedPitch flag set, and second its augmenting that with a list of known fonts from Apple that it considers monospace even without that flag being set.

Setting the flag for this font should be incorrect because while all the glyphs have the same width and it is designed for use as monospace font, there are in fact valid glyphs in it that have a different advance size—specifically some zero-width glyphs.

If Font Book was doing something sane like looking at the post script name tables and looking for suggestions that this was intended as a monospace font it would have found the correct properties set. Even guessing from the name wouldn't be the end of the world, how many font names end in "* Mono" that aren't monospace? Additionally if they actually skimmed through the font and the relevant (non-zero-width) glyphs to see if they all have the same advance metrics it would have done fine. Note that other font managers (for example Font Manager on Linux) come to the correct conclusion.

Sometime back in 2018 FontForge changed when they set the isFixedPitch flag to be more strict and support more advanced font features. The mailing list and issue trackers are full of ensuing flame wars about what the "correct" handling should have been. Accommodate broken font managers like Font Book by faking flags that are technically incorrect? Or follow the specs for the benefit of apps that do the right thing?

Since I don't have a dog in that race and I don't think it will break this particular font in the wild we can probably get away with faking that flag. I'll mess about with how to force it.

Font Manager demo

alerque commented 3 years ago

Also for the record, however fontconfig is determining this, it's coming up with the correct answer:

$ fc-list :spacing=mono | grep Libertinus
/usr/share/fonts/OTF/LibertinusMono-Regular.otf: Libertinus Mono:style=Regular
somelinguist commented 3 years ago

Thanks for all of the helpful background info. I wasn't aware it was as difficult! I left more comments on the PR.