ryanoasis / nerd-fonts

Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more
https://NerdFonts.com
Other
55.13k stars 3.65k forks source link

Scaling inconsistency between text and glyphs #1056

Closed dstoliker closed 1 year ago

dstoliker commented 1 year ago

🗹 Requirements

🎯 Subject of the issue

Experienced behavior: After upgrading to the latest version of the Hack nerd font via homebrew, there is an an apparent inconsistency between text and glyph scaling. I have a command line prompt configured with Oh My Posh with powerline symbols. After upgrading my font to the latest version, the glyphs no longer line up vertically. The glyphs are now taller. See screenshots below.

Expected behavior: Text and glyphs should align as they did before the upgrade.

Example symbols: \ue0b6 \ue0b4

🔧 Your Setup

★ Screenshots (Optional)

Powerline bar as it appeared before font package upgrade:

before update

After upgrade:

after update

iTerm2 font settings:

font settings
Finii commented 1 year ago

Sorry to hear that. Can see the differences...

image

Finii commented 1 year ago

Thanks for reporting. And thanks for a complete report with all the details I need to reproduce :+1:

Finii commented 1 year ago

image

image

Finii commented 1 year ago

Oh man, do I hate the metrics inconsistencies :unamused:

And whats this image

Finii commented 1 year ago

On my machine with tilix

image

When I can see it, it should be 'easy' to fix.

Finii commented 1 year ago

I think I found the reason.

Introduced a gap-redistribution with #943 The problem is that the gap is always redistributed, even if the font is based on the old WIN metrics. That does not have a gap :roll_eyes:

Rewriting the gap stuff right now.

Thanks again for reporting!


Useful links

In fontforge we have (example for ascent)

sourceFont.os2_winascent
sourceFont.os2_typoascent
sourceFont.hhea_ascent
sourceFont.ascent       <=- what is represented by this
Finii commented 1 year ago

Systematic examination of all source fonts regarding vertical metrics, one file of each font chosen at random.

find src/unpatched-fonts -iname '*.[ot]tf' | \
  sed -E 's! !\\!g;s!([^/]*/[^/]*/[^/]*).*!\0 \1!' | \
  sort | uniq -f 1 | sed 's! .*!!;s!\\! !g;s!^!"!;s!$!"!' | \
  xargs font-line report
Font hhea/UPM typo/UPM win/UPM use typo metrics gap win/mac note
3270 1.09 1.0 1.09 X X :red_square: forgot to set typo-gap?
Agave 1.12 1.0 1.12 X :red_square:
Anonymous 1 1 1 :heavy_check_mark:
Arimo 1.15 1.09 1.15 X :heavy_check_mark:
Aurulent 1.3 1.09 1.3 X :heavy_check_mark:
BigBlue 1 1 1 X :heavy_check_mark:
Bitstream Vera 1.16 1.2 1.16 X :heavy_check_mark:
Cascadia 1.16 1.16 1.32 X :heavy_check_mark:
CodeNewRoman 1.17 1.17 1.17 X :heavy_check_mark:
Couisine 1.13 0.842 1.13 :heavy_check_mark:
DaddyTime 1.25 1.25 1.25 X :heavy_check_mark:
DejaVu 1.16 1.2 1,16 X :heavy_check_mark:
Droid 1.16 1.07 1.16 X :heavy_check_mark:
Fantasque 1.05 1.05 1.05 X X :heavy_check_mark:
Fira 1.23 1.23 1.23 X :heavy_check_mark:
Fira Mono 1.4 1.4 1.4 X :heavy_check_mark:
Gohu 1.18 1.18 1.18 X X :heavy_check_mark:
Go Mono 1.16 1.16 1.16 X :heavy_check_mark:
Hack 1.16 1.2 1.16 X :heavy_check_mark:
Hasklig 1.26 1 1.26 :heavy_check_mark:
HeavyData 1.15 1.09 1.15 X :heavy_check_mark:
Hermit 1.56 1.09 1.56 X X :red_square:
iA writer 1.3 1.3 1.3 X :heavy_check_mark:
IBM Plex 1.3 1.3 1.3 X :heavy_check_mark:
InconsolataGo 1.05 1.05 1.05 :heavy_check_mark:
Inconsolata 1.05 1.05 1.46 X :heavy_check_mark:
Inconsolata LGC 1.46 1 1.46 X :heavy_check_mark:
Iosevka 1.25 1.25 1.25 X X :heavy_check_mark:
JetBrains Mono 1.32 1.32 1.32 X :heavy_check_mark:
Lekton 1 1 1.7 :red_square:
Liberation 1.13 0.842 1.13 :heavy_check_mark:
Lilex 1.3 1.3 1.3 X :heavy_check_mark:
Meslo 1.55 1.59 1.55 X :heavy_check_mark:
Monofur 1 1 1 X :heavy_check_mark:
Monoid 1.33 1.33 1.33 X :heavy_check_mark:
Mononoki 1.12 1.2 1.12 X :heavy_check_mark:
M+ 1.49 1.09 1.49 X :heavy_check_mark:
Noto 1.17 1.17 1.17 :heavy_check_mark:
OpenDyslexic 3.58 1.94 3.58 :heavy_check_mark:
Overpass 1.53 1.27 1.53 X X :red_square:
ProFont 1.23 1.23 1.23 :heavy_check_mark:
ProggyClean 0.812 1 0.812 :heavy_check_mark:
Roboto 1.17 1.05 1.2 X :red_square: 'alomst ok'
ShareTech 1.13 1.13 1.13 :heavy_check_mark:
SourceCode 1.26 1 1.26 :heavy_check_mark:
SpaceMono 1.48 1.48 1.48 X :heavy_check_mark:
Terminus 1.1 1.09 1.1 X X :red_square: 'almost ok'
Tinos 1.15 1.04 1.15 X :heavy_check_mark:
Ubuntu 1.15 1.02 1.15 X :heavy_check_mark:
Ubuntu Mono 1 0.907 1 X :heavy_check_mark:
Victor Mono 1.41 1.41 1.41 X X :heavy_check_mark:

Most crucial is that WIN does use the other gaps?! See https://learn.microsoft.com/en-us/typography/opentype/spec/recom#baseline-to-baseline-distances

Finii commented 1 year ago

I will combine this with #1055

Finii commented 1 year ago

Problematic cases:

font behavior hhea typo win ymin ymax y height
3270 [2] 2180 2000 2180 406 1626 2032
Agave [2] 2304 2048 2304 512 1792 2304
Hermit [2] 1506 1092 1506 414 1000 1414
Lekton [1] 1000 1000 1697 585 1112 1697
Overpass [2] 1532 1266 1532 378 1062 1440
Roboto [3] 2.5% 2400 2150 2458 555 2163 2718
Terminus [3] 3% 1122 1090 1122 183 845 1028

[1] Mismatch detected, chooses TYPO [2] Mismatch detected, chooses WIN [3] Mismatch detected, following USE-TYPO-METRICS

All looks ok, except Lekton, the only font that selects TYPO. So changing algo to not guess but always use WIN in thoses cases

tjapro commented 1 year ago

Sorry, to ask this here but I cannot find what I want ...

@dstoliker Where/What is these glyphs (the ones right in the line begining)?

image

Finii commented 1 year ago

This rounded line? At 2570:

image

Finii commented 1 year ago

While doing v3.0.0 ... Lekton is still problematic, too big gaps between lines:

image

Lets have a look at the table from above:

image

Lekton was the only font that selected TYPO but we forced it to WIN, because not all glyphs fit into the values from TYPO. But that seems to be wrong. Examining the glyphs that are really bigger than the TYPO line spaces, these are only graphical glyphs that shall span multiple lines. So I guess we should revert that change and render Lekton with the TYPO values.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a new issue, complete the issue template with all the details necessary to reproduce, and mention this issue as reference.