fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
549 stars 102 forks source link

`seems_monospaced` condition triggered too easily in font without Latin characters #2831

Open arrowtype opened 4 years ago

arrowtype commented 4 years ago

Observed behavior

I am building and checking Noto Sans Nushü, a proportional font without Latin characters, and I’m getting the following FAIL:

    * FAIL: On monospaced fonts, the value of post.isFixedPitch must be set to a non-zero value (meaning 'fixed width monospaced'), but got 0 instead. [code: mono-bad-post-isFixedPitch]

    * FAIL: On monospaced fonts, the value of OS/2.panose.bProportion must be set to 9 (proportion: monospaced), but got 0 instead. [code: mono-bad-panose-proportion]

This seems to be triggered by FontBakery comparing widths of ASCII characters (due to https://github.com/googlefonts/fontbakery/pull/2349) with the following code:

https://github.com/googlefonts/fontbakery/blob/547630259405878ebf924ceeb99f05ec8e67ca78/Lib/fontbakery/profiles/shared_conditions.py#L149-L171

However, this font only has space from ASCII u+0020, so that single glyph registers as "100% of ASCII is the same width" and triggers this fail.

Expected behavior

Probably, we need to restrict the seems_monospaced condition a little further. Something like

# if "number of ASCII characters" > 26:
    # check whether characters have matching widths

(26 may not be the correct number, but that would check for the basic Latin alphabet plus at least one more glyph, e.g. the space.)

felipesanches commented 4 years ago

so, do you think it would be good to have the same 80% threshold but for the most_common_width in cases where latin glyphs are not avaiable?

drj11 commented 4 years ago

As a counter are there real fonts that people think of as monospaced that don't have all their glyphs with the same width?

drj11 commented 4 years ago

I think it's too easily triggered for font with Latin characters too. I have a font that is "nearly" monospace: https://gitlab.com/drj11/arch8/-/tree/main/quazatron

It has two glyphs (W and M) that are not the same width as all the others. But it would be wrong to mark it as monospace.

It still trips over the the monospace checks. For com.google.fonts/check/monospace:

* FAIL: On monospaced fonts, the value of post.isFixedPitch must be set to a non-zero value (meaning 'fixed width monospaced'), but got 0 instead. [code: mono-bad-post-isFixedPitch]
* FAIL: On monospaced fonts, the value of OS/2.panose.bProportion must be set to 9 (proportion: monospaced), but got 1 instead. [code: mono-bad-panose-proportion]
* WARN: Font is monospaced but 2 glyphs (4.761904761904762%) have a different width. You should check the widths of: ['M', 'at'] [code: mono-outliers]