githubnext / monaspace

An innovative superfamily of fonts for code
https://monaspace.githubnext.com
SIL Open Font License 1.1
13.12k stars 219 forks source link

Resolve several major issues: Vertical Metrics, Monospace Recognition #227

Open ottta opened 1 month ago

ottta commented 1 month ago

This PR only tweaks all vertical metrics and font info on each .glyphs file

1. Avoid write lastChange and displayString to version control

2. Check Use Typo Metrics to get more consistent vertical metrics

3. Resolve #21 #37 #169

Note that "Gcommaaccent" may be truncated in environments that have overflow: hidden.

Please see these documentation:

4. Resolve #111 not recognized as monospace font Because isFixedPitch is not set, the record in the POST Table isFixedPitch has zero value. Please refer to these:

These images below illustrate Aring on the overflow: hidden environment

Before: Top of Aring seems clipping because miss configuration typo/hhea

before-argon-bold

After: Resolve clipping and vertically balance basic latin

after-argon-bold
Finii commented 3 weeks ago

Comment on commit 972eb52 Check Use Typo Metrics to get more consistent vertical metrics

More important would be to just make all 3 metrices the same (already the case), and avoid using gap values.

Hmm, and then the released font does already have that set, see here:

fini@Air ~ % font-line report ~/Downloads/monaspace-v1.101/fonts/otf/MonaspaceArgon-Regular.otf
=== /Users/fini/Downloads/monaspace-v1.101/fonts/otf/MonaspaceArgon-Regular.otf ===
Version 1.101 (Monaspace Argon)
SHA1: 02edd009f5cf7e196e311e7167dbf62b6fac3806

::::::::::::::::::::::::::::::::::::::::::::::::::
  Metrics
::::::::::::::::::::::::::::::::::::::::::::::::::
[head] Units per Em:   2000
[head] yMax:           1951
[head] yMin:          -760
[OS/2] CapHeight:      1460
[OS/2] xHeight:        1027
[OS/2] TypoAscender:   1565
[OS/2] TypoDescender: -435
[OS/2] WinAscent:      1878
[OS/2] WinDescent:     522
[hhea] Ascent:         1565
[hhea] Descent:       -435

[hhea] LineGap:        400
[OS/2] TypoLineGap:    400

::::::::::::::::::::::::::::::::::::::::::::::::::
  Ascent to Descent Calculations
::::::::::::::::::::::::::::::::::::::::::::::::::
[hhea] Ascent to Descent:              2000
[OS/2] TypoAscender to TypoDescender:  2000
[OS/2] WinAscent to WinDescent:        2400

::::::::::::::::::::::::::::::::::::::::::::::::::
  Delta Values
::::::::::::::::::::::::::::::::::::::::::::::::::
[hhea] Ascent to [OS/2] TypoAscender:       0
[hhea] Descent to [OS/2] TypoDescender:     0
[OS/2] WinAscent to [OS/2] TypoAscender:    313
[OS/2] WinDescent to [OS/2] TypoDescender:  87

::::::::::::::::::::::::::::::::::::::::::::::::::
  Baseline to Baseline Distances
::::::::::::::::::::::::::::::::::::::::::::::::::
hhea metrics: 2400
typo metrics: 2400
win metrics:  2400

[OS/2] fsSelection USE_TYPO_METRICS bit set: True

::::::::::::::::::::::::::::::::::::::::::::::::::
  Ratios
::::::::::::::::::::::::::::::::::::::::::::::::::
hhea metrics / UPM:  1.2
typo metrics / UPM:  1.2
win metrics  / UPM:  1.2
fini@Air ~ %
ottta commented 3 weeks ago

Comment on commit 972eb52 Check Use Typo Metrics to get more consistent vertical metrics

More important would be to just make all 3 metrices the same (already the case), and avoid using gap values.

Hmm, and then the released font does already have that set, see here:

fini@Air ~ % font-line report ~/Downloads/monaspace-v1.101/fonts/otf/MonaspaceArgon-Regular.otf
=== /Users/fini/Downloads/monaspace-v1.101/fonts/otf/MonaspaceArgon-Regular.otf ===
Version 1.101 (Monaspace Argon)
SHA1: 02edd009f5cf7e196e311e7167dbf62b6fac3806

::::::::::::::::::::::::::::::::::::::::::::::::::
  Metrics
::::::::::::::::::::::::::::::::::::::::::::::::::
[head] Units per Em:   2000
[head] yMax:           1951
[head] yMin:          -760
[OS/2] CapHeight:      1460
[OS/2] xHeight:        1027
[OS/2] TypoAscender:   1565
[OS/2] TypoDescender: -435
[OS/2] WinAscent:      1878
[OS/2] WinDescent:     522
[hhea] Ascent:         1565
[hhea] Descent:       -435

[hhea] LineGap:        400
[OS/2] TypoLineGap:    400

::::::::::::::::::::::::::::::::::::::::::::::::::
  Ascent to Descent Calculations
::::::::::::::::::::::::::::::::::::::::::::::::::
[hhea] Ascent to Descent:              2000
[OS/2] TypoAscender to TypoDescender:  2000
[OS/2] WinAscent to WinDescent:        2400

::::::::::::::::::::::::::::::::::::::::::::::::::
  Delta Values
::::::::::::::::::::::::::::::::::::::::::::::::::
[hhea] Ascent to [OS/2] TypoAscender:       0
[hhea] Descent to [OS/2] TypoDescender:     0
[OS/2] WinAscent to [OS/2] TypoAscender:    313
[OS/2] WinDescent to [OS/2] TypoDescender:  87

::::::::::::::::::::::::::::::::::::::::::::::::::
  Baseline to Baseline Distances
::::::::::::::::::::::::::::::::::::::::::::::::::
hhea metrics: 2400
typo metrics: 2400
win metrics:  2400

[OS/2] fsSelection USE_TYPO_METRICS bit set: True

::::::::::::::::::::::::::::::::::::::::::::::::::
  Ratios
::::::::::::::::::::::::::::::::::::::::::::::::::
hhea metrics / UPM:  1.2
typo metrics / UPM:  1.2
win metrics  / UPM:  1.2
fini@Air ~ %

It appears to be identical, but it is not. See the differences below.

*The released version (old files: `fonts/otf/.otf`)**

before-argon-bold
Ascenders Descenders LineGap UPM
1565 -435 400 2000

(Ascender + Abs(Descender) + LineGap) / UPM = LineHeight (1565 + Abs(-435) + 400) / 2000 = 1.2

Note: LineGap value 400

However, the above metrics caused Latin Capital Letter to not vertically center across the vertical bounding box:

Reference: https://googlefonts.github.io/gf-guide/metrics.html#9-uppercases-should-be-centered-in-the-text-line

*The tweaked version (this PR: `fonts/ttf/.ttf`)**

after-argon-bold
Ascenders Descenders LineGap UPM
1930 -470 0 2000

(Ascender + Abs(Descender) + LineGap) / UPM = LineHeight (1930 + Abs(-470) + 0) / 2000 = 1.2

Note: LineGap value 0

Even though I changed the Ascenders, Descenders, and LineGap values, the line-height values remained the same as before and are consistent accross platforms.

Reference: https://googlefonts.github.io/gf-guide/metrics.html#8-linegap-values-must-be-0

Finii commented 3 weeks ago

Well, the matrices were all the same, at least the baseline to baseline distance. 🤷‍♀️

More important would be to just make all 3 metrices the same (already the case), and avoid using gap values.

That's what you did, and what I said one should do. Set gaps to zero, they are a headache for fonts that are intended for terminals anyhow.

If the matrices are the same they will be rendered the same and "use typo metrics" (which is useless anyhow, as you know if you read all the documentation) is superfluous. The problem is that some terminals ignore GAP, some put it half top and bottom, some on the bottom, some on the top. That also affects this "not vertically centered"; the problem depends on the terminal used and how it interprets (if at all) the GAP.

Just setting the use-typo-metrics usually does not change anything, as the typo values ought to be used in any case ;-)

Google fonts has some "suggestions" that one can follow or not, like this one

Screenshot 2024-06-07 at 23 46 24

If you think Google is God, of course one needs to follow.

And why do you link this, as like, it contradicts what I said, when it is exactly my point?

Screenshot 2024-06-07 at 23 46 40

I don't get it. Ciao.

ottta commented 3 weeks ago

Have you tried the .ttf files? And don't you see the difference?

Old MonaspaceArgonVarVF[wght,wdth,slnt].ttf

iTerm2 Screenshot 2024-06-08 at 9 10 17 PM

MacOS Terminal Screenshot 2024-06-08 at 9 11 21 PM

New MonaspaceKryptonVarVF.ttf exported from GlyphsApp (not in this PR)

iTerm2 Screenshot 2024-06-08 at 9 10 44 PM

MacOS Terminal Screenshot 2024-06-08 at 9 12 02 PM

Or from default HTML Button component

Google Chrome (Version 125.0.6422.142)

Screenshot 2024-06-08 at 10 06 53 PM

Safari (Version 17.4.1) Screenshot 2024-06-08 at 10 08 50 PM

Firefox (Version 122.0.1) Screenshot 2024-06-08 at 10 09 23 PM

Opera (Version: 109.0.5097.68) Screenshot 2024-06-08 at 10 09 59 PM