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

Bugfix vertical lines in powerline prompts

Open Finii opened this issue 2 years ago • 5 comments

Description

First part of solution:

[why] For some powerline symbols we add a certain amount of overlap into the previous or next character to cover up a small gap between the symbols that otherwise can show up as ugly thin (usually colored) line.

But after we carefully design that glyph with a bit overlap (over-sized and having negative bearings) we remove all bearings. That breaks of course the glyph and no actual overlap on the left side happens.

[how] Just do not remove negative bearings on overlap-enabled glyphs. As they are rescaled in both directions anyhow all bearings are wanted and must be kept.

Second part of solution:

[why] With the previous commit the gap between powerline glyphs became much
better, but a faint line is still visible for LCD antialiasing (on my
machine).

Having seen how big the overlap is for Cascadia Code the overlap here
can be increase maybe a bit.

[how] Increase the overlap to 3 % (from mostly 2 %) for the glyphs that have a
'full colored edge' on one side.

Fixes: #29

Requirements / Checklist

What does this Pull Request (PR) do?

Increase the overlap for some glyphs slightly and correct the needed negative left side bearings for glyphs that should have had an overlap on the left side but had not.

How should this be manually tested?

Any background context you can provide?

The issue comes up relatively often, I think. I was never bothered by the lines, so I dod not really follow that. Maybe I'm wrong. I have real list of Issues that are related.

What are the relevant tickets (if any)?

#29

Also see #779 for params future as dict.

Screenshots (if appropriate or helpful)

@MIvanchev used LiterationMono Nerd Font Mono and neovim-Qt, so I use that here as examples. Note: Hinting full, Subpixel antialiasing, X11

Current behavior (before the PR):

overlap0 image

After fixing the code: (first part)

overlap1 image Note more pronounced line for round things, as that has only 1%, the other have 2% overlap

After increasing the overlap: (second part)

overlap2 image

I guess 3% is enough, it is still very very faintly visible. Can be increased if users still complain

Finii avatar Feb 07 '22 15:02 Finii

Issue not completely fixed, needs probably 4% of overlap. See https://github.com/ryanoasis/nerd-fonts/issues/29#issuecomment-1031639635

Okay... let's pretend to be scientific...

Cascadia has this overlap: image

Left negative bearing is 100, total width is 1200, this is well... 8% overlap horizontally.

But vertically, the glyph extends from 2226 to -480 while we have these metrics:

image

So there is virtually no overlap.

I will increase to 4% and limit vertical overlap to 1% as this will become ugly if stretched too much vertically.

Finii avatar Feb 07 '22 16:02 Finii

I see no problem with the 1% v-overlap.

Holy cow, the 'arrow up' glyph is tiny with that (i.e. Literation) font... (compare to underlying window with Cascadia)

image

Edit: Arrow is u_2191 and not patched in by us, it's just the font that has it so small :sweat_smile:

Finii avatar Feb 07 '22 16:02 Finii

Maybe I should check out Cascadia... I do like Liberation a lot but some stuff are not OK.

MIvanchev avatar Feb 07 '22 16:02 MIvanchev

Just as that is kind of related... When using Windows Terminal: https://github.com/microsoft/terminal/issues/12601

Keep it here for reference if Issues turn up ;)

Finii avatar Mar 03 '22 16:03 Finii

Tested out this PR with JetBrainsMono in Neovide and it seem to mess up the offset of some glyphs. For example, the half-circle looks like this: image (the character is supposed to be in the first, leftmost column) The other pair () seems fine though: image

musjj avatar Aug 24 '22 06:08 musjj

@musjj I guess you used the non-Mono version, i.e. JetBrainsMono Nerd Font (and not JetBrainsMono Nerd Font Mono).

Something seems to be wrong with the scaling in the non-Mono fonts. I will try neovide, if it's not too complicated :grimacing: or maybe neovim-qt first, I believe I have that installed already.

Finii avatar Oct 14 '22 06:10 Finii

Hmm, neovim-qt does render it like this:

image

It allows the upper D shape thing to extend into the right cell, but cuts off the stuff that extrudes into the left cell for the inverse D thing on the lower line.

Hmm, and this is neovide

image

Both D shape things extend on both sided, as encoded in the font. (That is a bug in the font, but anyhow)

So I can not reproduce @musjj My version is freshly downloaded from https://github.com/neovide/neovide/releases/latest/download/neovide.tar.gz (reports Neovide 0.10.1)

Finii avatar Oct 14 '22 10:10 Finii

What's the status here friends? Should this be merged or at least rebased? It aged a bit...

MIvanchev avatar Jan 11 '23 16:01 MIvanchev

I'd still love to see this fixed. 🙂

LandonSchropp avatar Jan 11 '23 19:01 LandonSchropp

I'll rebase later, not sure if this should go into 2.3.0 or not :thinking:

Finii avatar Jan 11 '23 19:01 Finii

A rebase would be enough for now as I can patch manually :}

Thanks I really appreciate it because it allows me to continue using Neovim-qt.

MIvanchev avatar Jan 12 '23 09:01 MIvanchev

Rebase on feature/allow-downscaling-nonmono (i.e. #748), which fixes a lot of scaling issues.

Force push.

Finii avatar Jan 12 '23 12:01 Finii

@MIvanchev

Hmm, I fixed some mathematical bug in the overlap formula (b3c079d), and now the overlap imposed on the glyphs by the same overla-percentage-value can be / is smaller. Maybe you can check if it is still good with 4%?

Finii avatar Jan 12 '23 13:01 Finii

On it! Thank you @Finii

MIvanchev avatar Jan 12 '23 13:01 MIvanchev

Merged the other PR, rebase on master, force push. It had yet another scaling and overlap fix :grimacing:

All the changes (apart from increasing the overlap percentages) are merged now, so the changes here are trivial. I'm not sure how Windows Terminal handles the (bigger) overlap, one would need to investigate that before we merge this. But otoh, Cascadia Code also does have overlap through negative bearings for the powerline glyphs, so it should work.

Finii avatar Jan 12 '23 16:01 Finii

I have no recollection why we did not increase the other overlaps... Any hints, or should they also go to 4%?

image

Finii avatar Jan 12 '23 16:01 Finii

I have no idea as well, still testing :) Will be back shortly!

MIvanchev avatar Jan 12 '23 16:01 MIvanchev

Thanks for all your hard free work!

MIvanchev avatar Jan 12 '23 16:01 MIvanchev

I'm having some issues testing because the patcher sets weight to Book vs Regular. Is there a way to change this @Finii

MIvanchev avatar Jan 12 '23 16:01 MIvanchev

Which font do you patch? Usually the weight is kept. If the patcher detects the correct one. But Book is only used if the original font somehow mentioned that. You can try to --makegroups which uses the 'new' font naming engine that is a bit better.

Finii avatar Jan 12 '23 17:01 Finii

I used LiberationMono Regular from https://github.com/liberationfonts/liberation-fonts/files/7261482/liberation-fonts-ttf-2.1.5.tar.gz, will test --makegroups in a bit :)

MIvanchev avatar Jan 12 '23 22:01 MIvanchev

Hmm,

$ tar zxf liberation-fonts-ttf-2.1.5.tar.gz
$ find *ttf-2.1.5 -name '*.ttf' -exec fontforge ~/git/nerd-fonts/font-patcher {} \;
$ fontforge ~/git/nerd-fonts/bin/scripts/name_parser/query_names *.ttf 2>/dev/null
Examining 12 font files
 |Filename                                           | | Fullname                                                          | | Family                                                  | | Subfamily                      | | Typogr. Family                           | | Typogr. Subfamily
 |-------------------------------------------------- |-| ------------------------------------------------------------      |-| ------------------------------------------------------- |-| ------------------------------ |-| ---------------------------------------- |-| ----------------------------------------
 |Literation Mono Bold Italic Nerd Font.ttf          | | Literation Mono Bold Italic Nerd Font                             | | LiterationMono Nerd Font                                | | Bold Italic                    | | LiterationMono Nerd Font                 | |
 |Literation Mono Bold Nerd Font.ttf                 | | Literation Mono Bold Nerd Font                                    | | LiterationMono Nerd Font                                | | Bold                           | | LiterationMono Nerd Font                 | |
 |Literation Mono Italic Nerd Font.ttf               | | Literation Mono Italic Nerd Font                                  | | LiterationMono Nerd Font                                | | Italic                         | | LiterationMono Nerd Font                 | |
 |Literation Mono Nerd Font.ttf                      | | Literation Mono Nerd Font                                         | | LiterationMono Nerd Font                                | | Book                           | | LiterationMono Nerd Font                 | |
 |Literation Sans Bold Italic Nerd Font.ttf          | | Literation Sans Bold Italic Nerd Font                             | | LiterationSans Nerd Font                                | | Bold Italic                    | | LiterationSans Nerd Font                 | |
 |Literation Sans Bold Nerd Font.ttf                 | | Literation Sans Bold Nerd Font                                    | | LiterationSans Nerd Font                                | | Bold                           | | LiterationSans Nerd Font                 | |
 |Literation Sans Italic Nerd Font.ttf               | | Literation Sans Italic Nerd Font                                  | | LiterationSans Nerd Font                                | | Italic                         | | LiterationSans Nerd Font                 | |
 |Literation Sans Nerd Font.ttf                      | | Literation Sans Nerd Font                                         | | LiterationSans Nerd Font                                | | Book                           | | LiterationSans Nerd Font                 | |
 |Literation Serif Bold Italic Nerd Font.ttf         | | Literation Serif Bold Italic Nerd Font                            | | LiterationSerif Nerd Font                               | | Bold Italic                    | | LiterationSerif Nerd Font                | |
 |Literation Serif Bold Nerd Font.ttf                | | Literation Serif Bold Nerd Font                                   | | LiterationSerif Nerd Font                               | | Bold                           | | LiterationSerif Nerd Font                | |
 |Literation Serif Italic Nerd Font.ttf              | | Literation Serif Italic Nerd Font                                 | | LiterationSerif Nerd Font                               | | Italic                         | | LiterationSerif Nerd Font                | |
 |Literation Serif Nerd Font.ttf                     | | Literation Serif Nerd Font                                        | | LiterationSerif Nerd Font                               | | Book                           | | LiterationSerif Nerd Font                | |

Indeed what would be Regular is Book.

$ fontforge ~/git/nerd-fonts/bin/scripts/name_parser/query_names liberation-fonts-ttf-2.1.5/*.ttf 2>/dev/null
Examining 12 font files
 |Filename                                           | | Fullname                                                          | | Family                                                  | | Subfamily                      | | Typogr. Family                           | | Typogr. Subfamily
 |-------------------------------------------------- |-| ------------------------------------------------------------      |-| ------------------------------------------------------- |-| ------------------------------ |-| ---------------------------------------- |-| ----------------------------------------
 |LiberationMono-BoldItalic.ttf                      | | Liberation Mono Bold Italic                                       | | Liberation Mono                                         | | Bold Italic                    | |                                          | |
 |LiberationMono-Bold.ttf                            | | Liberation Mono Bold                                              | | Liberation Mono                                         | | Bold                           | |                                          | |
 |LiberationMono-Italic.ttf                          | | Liberation Mono Italic                                            | | Liberation Mono                                         | | Italic                         | |                                          | |
 |LiberationMono-Regular.ttf                         | | Liberation Mono                                                   | | Liberation Mono                                         | | Regular                        | |                                          | |
 |LiberationSans-BoldItalic.ttf                      | | Liberation Sans Bold Italic                                       | | Liberation Sans                                         | | Bold Italic                    | |                                          | |
 |LiberationSans-Bold.ttf                            | | Liberation Sans Bold                                              | | Liberation Sans                                         | | Bold                           | |                                          | |
 |LiberationSans-Italic.ttf                          | | Liberation Sans Italic                                            | | Liberation Sans                                         | | Italic                         | |                                          | |
 |LiberationSans-Regular.ttf                         | | Liberation Sans                                                   | | Liberation Sans                                         | | Regular                        | |                                          | |
 |LiberationSerif-BoldItalic.ttf                     | | Liberation Serif Bold Italic                                      | | Liberation Serif                                        | | Bold Italic                    | |                                          | |
 |LiberationSerif-Bold.ttf                           | | Liberation Serif Bold                                             | | Liberation Serif                                        | | Bold                           | |                                          | |
 |LiberationSerif-Italic.ttf                         | | Liberation Serif Italic                                           | | Liberation Serif                                        | | Italic                         | |                                          | |
 |LiberationSerif-Regular.ttf                        | | Liberation Serif                                                  | | Liberation Serif                                        | | Regular                        | |                                          | |

And it is not from the sourcefont.

Investigating

Finii avatar Jan 13 '23 05:01 Finii

At least the 'new' method does is as expected:

$ rm *.ttf
$ find *ttf-2.1.5 -name '*.ttf' -exec fontforge ~/git/nerd-fonts/font-patcher --makegroups {} \;
$ fontforge ~/git/nerd-fonts/bin/scripts/name_parser/query_names *.ttf 2>/dev/null
Examining 12 font files
 |Filename                                           | | Fullname                                                          | | Family                                                  | | Subfamily                      | | Typogr. Family                           | | Typogr. Subfamily
 |-------------------------------------------------- |-| ------------------------------------------------------------      |-| ------------------------------------------------------- |-| ------------------------------ |-| ---------------------------------------- |-| ----------------------------------------
 |Literation Mono Nerd Font Bold Italic.ttf          | | Literation Mono Nerd Font Bold Italic                             | | LiterationMono Nerd Font                                | | Bold Italic                    | |                                          | |
 |Literation Mono Nerd Font Bold.ttf                 | | Literation Mono Nerd Font Bold                                    | | LiterationMono Nerd Font                                | | Bold                           | |                                          | |
 |Literation Mono Nerd Font Italic.ttf               | | Literation Mono Nerd Font Italic                                  | | LiterationMono Nerd Font                                | | Italic                         | |                                          | |
 |Literation Mono Nerd Font.ttf                      | | Literation Mono Nerd Font                                         | | LiterationMono Nerd Font                                | | Regular                        | |                                          | |
 |Literation Sans Nerd Font Bold Italic.ttf          | | Literation Sans Nerd Font Bold Italic                             | | LiterationSans Nerd Font                                | | Bold Italic                    | |                                          | |
 |Literation Sans Nerd Font Bold.ttf                 | | Literation Sans Nerd Font Bold                                    | | LiterationSans Nerd Font                                | | Bold                           | |                                          | |
 |Literation Sans Nerd Font Italic.ttf               | | Literation Sans Nerd Font Italic                                  | | LiterationSans Nerd Font                                | | Italic                         | |                                          | |
 |Literation Sans Nerd Font.ttf                      | | Literation Sans Nerd Font                                         | | LiterationSans Nerd Font                                | | Regular                        | |                                          | |
 |Literation Serif Nerd Font Bold Italic.ttf         | | Literation Serif Nerd Font Bold Italic                            | | LiterationSerif Nerd Font                               | | Bold Italic                    | |                                          | |
 |Literation Serif Nerd Font Bold.ttf                | | Literation Serif Nerd Font Bold                                   | | LiterationSerif Nerd Font                               | | Bold                           | |                                          | |
 |Literation Serif Nerd Font Italic.ttf              | | Literation Serif Nerd Font Italic                                 | | LiterationSerif Nerd Font                               | | Italic                         | |                                          | |
 |Literation Serif Nerd Font.ttf                     | | Literation Serif Nerd Font                                        | | LiterationSerif Nerd Font                               | | Regular                        | |                                          

I would advise anyone to always use --makegroups, at least when patching more than one font in a group. At some point in the future the 'old' mathod will be dropped as it has more than 2 and 1/2 known bugs.

Finii avatar Jan 13 '23 05:01 Finii

Lets separate the issues and discuss here only the vertical lines. Created new Issue #1046

Finii avatar Jan 13 '23 06:01 Finii

Possible to get another rebase to account for the naming issues? :))

MIvanchev avatar Jan 13 '23 13:01 MIvanchev

Here you are.

Grump, it runs the PackSVG workflow ... sigh

Finii avatar Jan 13 '23 14:01 Finii

Thanks in case you're wondering why I don't rebase myself, there's a slight issue with the repo size ;)

MIvanchev avatar Jan 13 '23 14:01 MIvanchev

So all of my issues are resolved currently, I see no glitching.

MIvanchev avatar Jan 13 '23 14:01 MIvanchev

It's by far the biggest singe thing on my laptop:

image

(light red chunk)

:-D

Finii avatar Jan 13 '23 14:01 Finii

Increasing the overlap introduces issues with some terminal emulators. The lines are usually an artifact from subpixel rendering and can be avoided if the user turns on greyscale-antialiasing.

Anyhow, as terminals behave differently, if we improve the situation for one it will get worse for another.

Maybe we can live with what we have now. Moving this to the Parallel Universe.

Finii avatar Mar 10 '23 11:03 Finii