nerd-fonts icon indicating copy to clipboard operation
nerd-fonts copied to clipboard

Patcher reduces the spacing between lines making fonts difficult to read.

Open BoltsJ opened this issue 2 years ago β€’ 3 comments

πŸ—Ή Requirements

  • [x] I have searched the issues for my issue and found nothing related and/or helpful
  • [x] I have searched the FAQ for help
  • [x] I have searched the Wiki for help

🎯 Subject of the issue

Experienced behavior: After patching a font, the line height is reduced which makes

Expected behavior: Line height should remain the same after patching.

Example symbols: N/A

πŸ”§ Your Setup

  • Which font are you using (e.g. Anonymice Powerline Nerd Font Complete.ttf)?
    • Comic Code Regular Nerd Font Complete.otf
    • Self-patched using the oci image.
  • gnome-terminal, Blackbox, gnome-text-editor
  • Fedora 36 Silverblue

β˜… Screenshots (Optional)

Unpatched font: image

Patched font: image

BoltsJ avatar Jun 27 '22 18:06 BoltsJ

The same thing happens to me when patching comic code ligatures

bartdorsey avatar Jul 25 '22 23:07 bartdorsey

image

I guess that is very easy to fix. Believe I know where the size is lost.

Finii avatar Jul 26 '22 11:07 Finii

image

I guess that is very easy to fix. Believe I know where the size is lost.

Could you share your insights?

plodocus avatar Aug 06 '22 07:08 plodocus

I am facing the same issue, is there a known fix yet ? I am trying to patch MonoLisa.

Edit:

I found a quick and dirty fix, Just comment these lines in font-patcher script:

self.sourceFont.hhea_linegap = 0
self.sourceFont.os2_typolinegap = 0 

The code is suppose to fix powerline related glyphs, however, if you don't care about them then commenting above lines should fix the issue.

tusharsnx avatar Sep 25 '22 07:09 tusharsnx

@tusharsnn :+1:

I'm not sure the font-patcher code is correct in this regard anyhow.

:thinking: Obviously I commented already some time back :grimacing:

This needs some research in the src/unpatched-fonts base, which might take me some time. Feel free to ping me from time to time :grimacing:

This is the commit that added the lnes you mention: 9770856f83 Zero out linegap values to allow power line glyphs to fill properly

And probably it is right, but we have to keep the gap in another property then, we can not just silently remove it without replacement.

Finii avatar Sep 26 '22 09:09 Finii

I should point out that MonoLisa is aligned towards the top instead of being centered, which means there is more gap on the bottom then it is on the top. Is that fonts with this characteristic is effected by mentioned code or is there are other cases aswell ?

tusharsnx avatar Sep 26 '22 10:09 tusharsnx

Fonts that have a linegap set (only regular shown):

3270Medium                                         Line gap: 90 (90)     [x]
Arimo                                              Line gap: 67 (307)    [ ]
VeraMono                                           Line gap: 0 (410)     [ ]
DejaVuSansMono                                     Line gap: 0 (410)     [ ]
FantasqueSansMono                                  Line gap: 50 (100)    [x]
gohufont*                                          Line gap: 377 (377)   [x]
Go-Mono                                            Line gap: 0 (393)     [ ]
Hack                                               Line gap: 0 (410)     [ ]
heavy_data                                         Line gap: 67 (307)    [ ]
iAWriter*                                          Line gap: 0 (300)     [ ]
IBMPlexMono                                        Line gap: 0 (300)     [ ]
Inconsolata-LGC                                    Line gap: 205 (0)     [ ]
iosevka*                                           Line gap: 68 (0)      [x]
LiberationS*                                       Line gap: 67 (307)    [ ]
Lilex                                              Line gap: 0 (600)     [ ]
Meslo LG *                                         Line gap: 0 (1210)    [ ]
mononoki                                           Line gap: 0 (229)     [ ]
mplus-*                                            Line gap: 90 (90)     [ ]
RobotoMono                                         Line gap: 0 (102)     [ ]
Terminus                                           Line gap: 90 (90)     [x]
Tinos                                              Line gap: 87 (307)    [ ]
Ubuntu-*                                           Line gap: 28 (56)     [ ]
VictorMono*                                        Line gap: 200 (200)   [x]

Name ...                                           hhea_linegap (typolinegap) [use_typo_metrics]

https://www.high-logic.com/font-editor/fontcreator/tutorials/font-metrics-vertical-line-spacing https://glyphsapp.com/learn/vertical-metrics https://silnrsi.github.io/FDBP/en-US/Line_Metrics.html

Finii avatar Sep 26 '22 12:09 Finii

Victor Mono:

image

VictorMono Nerd Font:

image

Hmm, for my eye the spacing is 'too loose' in the original font. If we fix this people might complain now the patched fonts are wrong :grimacing:

Finii avatar Sep 26 '22 12:09 Finii

Downloaded Comic Code from myfonts ...:

ComicCodeDemo                                      Line gap: 200 (200) [x]

image

After patching:

image

Finii avatar Sep 26 '22 13:09 Finii

Maybe add option to 'keep line distance', but turned off for prepatched fonts? Opinions?

Edit: Both instanced in the Issue are self-patched fonts

Finii avatar Sep 26 '22 13:09 Finii

IMO the tool (or at least the ./font-patcher) should not override original font properties by default. For already patched fonts this should be explicitly mentioned that spacing has been modified.

tusharsnx avatar Sep 26 '22 13:09 tusharsnx

But people will complain if the visuals of their beloved patched fonts change with an Nerd Font update. They do not care what is 'right' or 'wrong' as long as it is the same as before the update :grimacing: ;-)

Thanks for the opinion!

Finii avatar Sep 26 '22 13:09 Finii

IF we use the line gap, there is another thing to decide on:

image

You see that the Powerline Triangular Thing is exactly on the same height as the middle of X - etc... If the Powerline glyph needs to fill further down, what will happen with that?

  • Move the tip further down, too low compared with - etc
  • Keep tip on middle X height, but clip (make unsymmetric)
  • Vary angles of the triangle (too much work probably)

Finii avatar Sep 26 '22 13:09 Finii

But people will complain if the visuals of their beloved patched fonts change with an Nerd Font update. They do not care what is 'right' or 'wrong' as long as it is the same as before the update 😬 ;-)

I agree with that, patched font should stay the same. And for self patching, 'keep line distance' flag should be enough.

tusharsnx avatar Sep 26 '22 13:09 tusharsnx

You see that the Powerline Triangular Thing is exactly on the same height as the middle of X - etc... If the Powerline glyph needs to fill further down, what will happen with that?

  • Move the tip further down, too low compared with - etc
  • Keep tip on middle X height, but clip (make unsymmetric)
  • Vary angles of the triangle (too much work probably)

I don't pretend to understand fontforge completely, but is it possible to centre the text AND divide the original line space evenly on top and bottom? that way we don't need to workaround glyphs to look right.

tusharsnx avatar Sep 26 '22 13:09 tusharsnx

Patched without removing line gap...:

image

image

but is it possible to centre the text AND divide the original line space evenly on top and bottom?

Excellent idea!

Edit: Add detail image

Finii avatar Sep 26 '22 13:09 Finii

AH! This font has no headroom! I have seen such patched fonts before, and they 'break' if people like to use diacritics like Ö (Big O with dots, Γ–) because it has no room. I have an issue about that somewhere... that would be solved if we keep the gap.

Finii avatar Sep 26 '22 13:09 Finii

Hmm....

Gap distributed to top and bottom, equally:

image

Finii avatar Sep 26 '22 14:09 Finii

This looks ok-isch? I will clean up the commit and test with some of the other problematic (i.e. gap-having) fonts.

Finii avatar Sep 26 '22 14:09 Finii

Here is the issue where the headroom is too small for umlauts.. tested with text Übelst...

  • https://github.com/ryanoasis/nerd-fonts/pull/593#issuecomment-801270215

Finii avatar Sep 26 '22 14:09 Finii

Hmm....

Gap distributed to top and bottom, equally:

image

Maybe it's an optical illusion, but it looks like the font is being stretched out here.

BoltsJ avatar Sep 26 '22 15:09 BoltsJ

Looks identical... (200% view) Note the vertical spacing between the ? boxes.

Original

image

Patched, with HEAD

image

Patched, gap left intact

image

Patched, gap redistributed top/bottom

image

Next to each other

image

Finii avatar Sep 26 '22 15:09 Finii

Superimposed 1st (original) and 4th (split gap) variant at 400%:

image

Finii avatar Sep 26 '22 16:09 Finii

patched with equal gaps looks good to me πŸ‘

tusharsnx avatar Sep 26 '22 16:09 tusharsnx

Sorry for necroposting, but I just patched my Comic Code and spacing between the lines has diminished. I used font-patcher version

Nerd Fonts Patcher v2.3.3 (3.5.1) executing
Nerd Fonts: font-patcher (2.3.3)

and alacritty

alacritty 0.11.0 (8dbaa0bb)

snpefk avatar Feb 06 '23 18:02 snpefk

I have the same issue as @snpefk. I patched Comic Code with font-patcher version v2.3.3 (3.5.1) and the line height is now much reduced and very cramped.

paldepind avatar Feb 15 '23 16:02 paldepind

@paldepind @snpefk Sorry to hear of your problems.

I introduced a bug in the line height calculations, and found that just a few days ago, let me check if your version(s) are what I believe fixed, or suffer that bug...

That were these commits

image

Here...

Refs: 2.2.0-RC-466-g62b972b43
Author:     Fini Jastrow <[email protected]>
AuthorDate: Sun Feb 12 16:35:20 2023 +0100
Commit:     Fini Jastrow <[email protected]>
CommitDate: Sun Feb 12 17:06:18 2023 +0100

    font-patcher: Fix: Use WIN metrics in all conflicting cases

    [why]
    With commit
      621008773  font-patcher: Use WIN metrics in all conflicting cases
    we intended to use the WIN metrics for the baseline to baseline
    calculations for fonts that have contradicting (i.e. broken) metrices.

    But we use the TYPO metrics instead.

    [how]
    This is obviously a typo in the code. To prevent such errors and improve
    the readability we use Enums now. I believe we silently dropped support
    for Python 2 some time back. And if not we drop it today :-}

    [note]
    Many thanks to Nathaniel Evan for again finding this bug!

    Mentioned in: #1116

    Signed-off-by: Fini Jastrow <[email protected]>
---
 font-patcher | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/font-patcher b/font-patcher
index b0c451358..a00eb7f37 100755
--- a/font-patcher
+++ b/font-patcher
@@ -6,7 +6,7 @@
 from __future__ import absolute_import, print_function, unicode_literals

 # Change the script version when you edit this script:
-script_version = "3.5.6"
+script_version = "3.5.7"

 version = "2.3.3"
 projectName = "Nerd Fonts"

So it should be re-fixed with version 3.5.7 while you have 3.5.1.

What do you use? Docker, zip-archive, ?

Finii avatar Feb 15 '23 18:02 Finii

  • #1116 (bottom)
  • #1117
  • 62b972b4310a320dadbe6f89fa1903cf4f0ab039 font-patcher: Fix: Use WIN metrics in all conflicting cases
  • b112fe12de77ca506dba366be0a7754d5988525b font-patcher: Fix: Fix line gap redistribution
  • e69a025a8d19135563731529b0d5cd93b87608c3 font-patcher: Fix line gap redistribution
  • 621008773c1864002a0c178715c062b4b3c9d36b font-patcher: Use WIN metrics in all conflicting cases

Finii avatar Feb 15 '23 18:02 Finii

I did not initiate a bugfix 2.3.x release because I believe we are very near 3.0.0; lthough ... I keep being pushed back :grimacing:

Finii avatar Feb 15 '23 18:02 Finii

Thanks a lot for the quick reply @Finii πŸ™‚

I got the patch script through the ZIP archive. How do I get 3.5.7? Then I'll be happy to check if this fixes the issue.

paldepind avatar Feb 16 '23 08:02 paldepind