You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hhea.numberOfHMetrics not correct for monospace #3014
Following that guidance, Fontbakery recently implemented a check that issues a FAIL if this is not set per Microsoft's recommendation.
However, as far as I can tell, fonttools does not consider whether a font is monospaced when calculating hhea.numberOfHMetrics. In my current project, I'm noting that I'm getting a value of 1010 out rather than 3. And evaluating a variety of monospace fonts in the Google Fonts library (as well as my own Cascadia Code which is built using fonttools), none list a hhea.numberOfHMetrics of 3.
I believe a special casing needs to be added to the hhea compile / decompile to account for monospace fonts.
Regardless of what fonttools will have to do, a fontbakery FAIL is rather overreaching, especially since the quoted recommendation uses the word "suggested".
Most monospace fonts these days are not truly "monospaced" because of zerowidth marks. That's probably why you see a large value calculated by fonttools.
Why does Microsoft recommend this? I assume it is based on their old advice that “Glyph 1 should have no contours and zero advance width”. That is, if the font’s monospace width is n, then .notdef has width n, glyph 1 has width 0, and the rest have width n. That requires a minimum of 3 longHorMetric records in 'hmtx'. However, that is an optimization; it’s not wrong for a font to have multiple trailing longHorMetric records with the same advanceWidth, it’s just inefficient. Therefore, a FAIL seems too strong.
Microsoft’s current advice doesn’t mention a special width for glyph 1 (.null) anymore. That means all glyphs in a monospace font could have the same width, so only 1 longHorMetric record is necessary, so hhea.numberOfHMetrics should be 1 (under a strict definition of monospace font, without zero-width marks).
I kind of got the sense that the 3 is to account for zerowidth marks and doublewidth CJK, (otherwise, wouldn't it just be 1?), but could be mistaken.
Yeah it doesn't work that way. The optimization is that all the glyphs at the tail of the font that have the same advance can be removed and encoded as just one entry...
if fontbakery's check merely asserts that hhea.numberofHMetrics == 3 "because the spec recommends so", then it is completely bogus and should simply be ignored/removed
Reacted by Felipe Corrêa da Silva Sanches, David Jones and Thomas Phinney
@madig suggested adding that FAIL. I have now downgraded it to a WARN and changed a bit the wording of the message, directing users to come read this conversation.
I'm open to further improving the check by either completely removing this WARN, or by making it more informative to the users.
Activity
justvanrossum commentedon Mar 1, 2023
Regardless of what fonttools will have to do, a fontbakery FAIL is rather overreaching, especially since the quoted recommendation uses the word "suggested".
behdad commentedon Mar 1, 2023
Most monospace fonts these days are not truly "monospaced" because of zerowidth marks. That's probably why you see a large value calculated by fonttools.
aaronbell commentedon Mar 1, 2023
I kind of got the sense that the
3is to account for zerowidth marks and doublewidth CJK, (otherwise, wouldn't it just be1?), but could be mistaken.dscorbett commentedon Mar 1, 2023
Why does Microsoft recommend this? I assume it is based on their old advice that “Glyph 1 should have no contours and zero advance width”. That is, if the font’s monospace width is n, then .notdef has width n, glyph 1 has width 0, and the rest have width n. That requires a minimum of 3 longHorMetric records in 'hmtx'. However, that is an optimization; it’s not wrong for a font to have multiple trailing longHorMetric records with the same advanceWidth, it’s just inefficient. Therefore, a FAIL seems too strong.
Microsoft’s current advice doesn’t mention a special width for glyph 1 (.null) anymore. That means all glyphs in a monospace font could have the same width, so only 1 longHorMetric record is necessary, so hhea.numberOfHMetrics should be 1 (under a strict definition of monospace font, without zero-width marks).
behdad commentedon Mar 1, 2023
Yeah it doesn't work that way. The optimization is that all the glyphs at the tail of the font that have the same advance can be removed and encoded as just one entry...
anthrotype commentedon Mar 1, 2023
if fontbakery's check merely asserts that
hhea.numberofHMetrics == 3"because the spec recommends so", then it is completely bogus and should simply be ignored/removedWARN when monospaced fonts have hhea.numberOfHMetrics != 3
WARN when monospaced fonts have hhea.numberOfHMetrics != 3
felipesanches commentedon Mar 3, 2023
@madig suggested adding that FAIL. I have now downgraded it to a WARN and changed a bit the wording of the message, directing users to come read this conversation.
I'm open to further improving the check by either completely removing this WARN, or by making it more informative to the users.
WARN when monospaced fonts have hhea.numberOfHMetrics != 3