-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hhea.advanceWidthMax might be a bad value to rely on for monospace_max_advancewidth check #2749
Comments
I am seeing that the
|
According to the specs, I think that the problem with com.google.fonts/check/monospace_max_advancewidth is the false assumption that all glyphs in a monospaced font would have the same advanceWidth as the maximum value. If the purpose of the check was to ensure that Also, we already have a check for ensuring And we also have a check for the advanceWidths of all glyphs that carefully determines which is the largest group of glyphs with the same value and then ensures such group corresponds to more than 80% of the glyphset, which is pretty reasonable to accommodate the eventual outliers. That's com.google.fonts/check/monospace, as @thundernixon mentioned above. So, my conclusion is that com.google.fonts/check/monospace_max_advancewidth was a mistake and has no actual usefulness, so it will be deprecated. If anyone knows of an actual value of keeping it (even if including changes to it's implementation) please let me know and I'll be glad to revert the deprecation, as long as we document the rationale for keeping it. |
So, there are instances in which the max advance width can cause issues if it is too wide, especially in some older code/terminal environments. For example: I know that Fira Code and Hasklig use a surprising approach to code ligatures, to ensure that everything stays within the same single-letter width. So, I don’t think it’s necessarily a terrible check, but the rationale definitely could use an upgrade. |
thanks, @thundernixon! |
Good plan! I’ll try to help think of something. Found some detail from the Fira Code author on why the libraries have single width, plus blank spaces: it makes it easier for programs to insert the cursor at the proper place. I know that even the terminal in VS Code gets messed up from proportional glyphs (somewhat surprising, because the code editor part has no trouble), though I think it probably uses average width rather than max width. https://www.patreon.com/posts/fira-code-inside-28074541 Input Mono describes some issues with editors and terminals that don’t support non-fixed-width fonts. This is probably slightly out of date, but likely some/many of the issues still exist. https://input.fontbureau.com/workarounds/ Fonts that aren’t marked as isFixedPitch will not show I up in many Windows software font menus (google/fonts#1824). So, perhaps there is another check for that, but if not, this check could maybe suggest that people set that to |
Maybe the rationale could be something like:
|
(Though, this ignores that I think code ligatures can be better as dlig than as calt. I need to try the Fira code width hack with dlig, to see whether that can work. If so, I could write a document on GitHub about the workflow, and we could link to that.) |
Observed behaviour
In Recursive Mono, I get notified that
This seems to be a monospaced font, so advanceWidth value should be the same across all glyphs, but 99.6% of them have a different value
.However, this assumes that the font's maximum width value is its primary width value, which is not the case here. Rather, the normal value is
600
units, and the maximum of2400
comes from only a few code ligatures.1099 of 1247 glyphs have a width of
600
, meaning that only 11.87% of them have a different value. Moreover, a check shows that all glyph widths are divisible by the normal width of600
with no remainder, so the font should theoretically have no issues of non-monospaced glyphs.Of course, some terminals (e.g. the VS Code terminal) will not work with glyphs over the 600-unit width, but those also don't support
dlig
, so the only problems I've run into in the VS Code terminal are:f.italic
gets cut off because it goes beyond its sidebearingsExpected behaviour
Instead of basing the "correct" monospace value on
hhea.advanceWidthMax
, I think it might make sense to base it on something like thespace
ora
glyph.If there is reason to base it on the
hhea.advanceWidthMax
, we should at least update the check rationale to say why we are flagging it as aWARN
, and perhaps calculate the "different value" metric.Resources and exact process needed to replicate
Here's a recent version of Recursive which can be used for this check:
https://github.com/arrowtype/recursive/blob/1a1680256d89d6856f9e4eef06ceae247a804537/fonts_1.036/Static_TTF/RecursiveMonoLnr-ExtraBold.ttf
The text was updated successfully, but these errors were encountered: