-
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
WARN Caps are averagely centred — v metrics check #4139
Comments
capsHeight - hhea/typoAscender ~= - hhea/typoDescender
(this is only recommended for fonts with Latin, Greek or Cyrillic as "main" script, I would go for allowing an error margin of 5% of UPM)
This would be a great check, there is a twitter thread going over the rationale in detail here: https://twitter.com/romanshamin_en/status/1562801657691672576 |
I made a pull request for a new check covering this issue here: #4226 |
tl;dr: you might want to do more testing and investigation before implementing that check? I just want to point out that there is a big assumption behind this, which I am very skeptical of: that all relevant environments people care about, do vertical centering of text using the same algorithm. I am especially a bit suspicious of the implied claim that em-square as a distance from the origin is one of the metrics in question. I would also be curious as to WHICH descender metric is relevant, or whether that might vary as well. In the case of Google’s own Flutter web framework, it appears to rely on sTypo metrics including sTypoAscender, and also possibly on… the baseline (?!). But I did not get enough feedback to be sure what was going on. See |
@tphinney Thanks for the feedback! I made a codepen here to try showing why this is a real issue: https://codepen.io/eliheuer/pen/KKrOamg This kind of vertical centering works on the Web (Chrome) which I would argue is the most relevant environment. And to me it also just intuitively makes sense that you would want to center things this way. This is only a WARN, so no one is forced to do this. But maybe this is a good best practice if you don't have any reason to do otherwise? Here is Martian Mono, which is perfectly centered (Top: 42px, Bottom: 42px): Here is Shantell Sans, which is NOT perfectly centered, but within the threshold to pass this test (Top: 46px, Bottom: 46px): Here is Amiri, which is off by enough that it would get a |
Clarification: I was writing about Roman Shemin’s Twitter thread and his version of the vertical metrics check, which is significantly different than what Rosa proposed. Which one are you doing? |
I tried to implement the check as described by Rosalie, including the error margin of 5%. upm = ttFont["head"].unitsPerEm
error_margin = upm * 0.05
cap_height = ttFont["OS/2"].sCapHeight
ascender = ttFont["hhea"].ascent
descender = ttFont["hhea"].descent
top_margin = ascender - cap_height
difference = abs(top_margin - abs(descender))
vertically_centered = difference <= error_margin |
I understand that the approach described on the Roman Shemin’s twitter thread can be useful. But isn't it too opinionated to expect that all fonts in the world should follow the same approach? In other words, is this proposal meant to result in a WARN-level |
I don't like the use of |
I feel like whatever proposed here is overly Anglo-centeric. You don’t even need Arabic, try some accented text and the perfectly centered fonts are no longer centered. This feel like trying to solve a non-font issue in fonts, since centering depends on the text and the container and it is something should be handled in CSS not in fonts. |
I agree with @khaledhosny. To me this proposed check looks like trouble. |
The in-person conversations at TypeCon 2023 convinced me it is a reasonable check. |
Yeah, as long as it is Rosalie’s version and not Roman Shemin’s it is… not crazy. 😛 |
If possible, the uppercase glyphs should be vertically centered in the em box. **com.google.fonts/check/caps_vertically_centered** Added to the Universal profile. (issue #4139)
This issue is a great example of this problem: mui/material-ui#29965 |
"If possible, the uppercase glyphs should be vertically centered in the em box." 'caps_vertically_centered' On the Universal Profile. (issues fonttools#4139 and fonttools#4274)
"If possible, the uppercase glyphs should be vertically centered in the em box." 'caps_vertically_centered' On the Universal Profile. (issues fonttools#4139 and fonttools#4274)
capsHeight - hhea/typoAscender ~= - hhea/typoDescender
(this is only recommended for fonts with Latin, Greek or Cyrillic as "main" script, I would go for allowing an error margin of 5% of UPM)We also had the experience with Braah One: google/fonts#6227
So also in case of non-caps fonts, we could have a similar rule.
The text was updated successfully, but these errors were encountered: