Skip to content
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

Odd gap between glyphs and text #29

Closed
mhartington opened this issue Sep 5, 2015 · 46 comments
Closed

Odd gap between glyphs and text #29

mhartington opened this issue Sep 5, 2015 · 46 comments

Comments

@mhartington
Copy link

Not sure what happened, but since updating my fonts to include the new icons, I'm getting some weird spacing between the powerline glyphs and regular text.

screen shot 2015-09-05 at 4 26 08 pm

Using other fonts that have powerline support do not have this issue.

@ryanoasis
Copy link
Owner

I've been away but I will look into this. I think one thing that needs to happen is to detect if the powerline characters are present in the font being patched and to not add (override) the already existing powerline glyphs.

per: #28 (comment)

@sethamclean
Copy link

I have the same issue using the pre-patched source code pro fonts

@kiranps
Copy link

kiranps commented Sep 14, 2015

@mhartington i think you are using tmux separator as | change it to "" blank

@dritter
Copy link

dritter commented Sep 15, 2015

@kiranps I don't think so. I have the same issue without using tmux..

@sethamclean
Copy link

I have the same problem with "Sauce Code Powerline Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.otf". My terminal is urxvt and I am seeing the gap in VIM with lightline.

@mudox
Copy link

mudox commented Sep 16, 2015

I can reproduce the gap by increasing the horizontal character spacing in iTerm2, maybe it's a editor/terminal font rendering issue.

@dritter
Copy link

dritter commented Sep 16, 2015

@mudox I left the character spacing untouched. And like @sethamclean I have it with "Sauce Code"-Font only. So this is definitely a font issue.

@sethamclean
Copy link

@mudox reducing the font spacing can remove the gap but the arrows are vertically too small as well. This results in a "road cone" like shape.

@mhartington
Copy link
Author

Yeah, using source code pro or hack, which has powerline support already, there isn't an issue.
So this is an issue where the glyphs that get patched are off by a pixel or two.

@ryanoasis
Copy link
Owner

I am working on not overwriting powerline glyphs if they are already present in the font to be patched.

I thought this actually may have been fixed for recently patched Sauce Code but ryanoasis/vim-devicons#126 seems to suggest otherwise. I have not tested yet.

@mhartington
Copy link
Author

Looking good! Happy to be closing this.

@voiprodrigo
Copy link

I have this problem, commented in #26

@ryanoasis
Copy link
Owner

@voiprodrigo thanks

@astrolemonade
Copy link
Contributor

2019, the issue is still present

@ryanoasis
Copy link
Owner

@cata0309 Could you attach a screenshot and give some more details (os, terminal, font and font size)?

I know it seems frustrating that this seemingly small issue may not be solved 100% for all scenarios but this is actually difficult to look perfect for all terms and fonts at all sizes. It seemed like this was solved and furthermore it made sense to spend time on the lower hanging fruit. Thanks

@astrolemonade
Copy link
Contributor

image
I am using Solus Linux Fortitude
Terminal: Gnome-terminal, tilda, tilix
font: Furacode NF Regular size 12
Name a terminal that shows the fonts right, I will install right away.

@spinnau
Copy link

spinnau commented Jul 2, 2019

@cata0309 I also see this effect in GNOME-Terminal 3.32.2 running on GNOME desktop. Testing different nerd fonts (DejaVu Sans Mono Regular, Fura Code Regular, Meslo LG L Regular, Sauce Code Pro) and font sizes from 9 to 14 doesn't solve the problem.

After testing some hinting and anti-aliasing settings in GNOME Tweak Tool I have found that the gaps disappear by changing the anti-aliasing from Subpixel to Grayscale.

With Subpixel anti-aliasing:
subpixel_antialiasing

With Standard (grayscale) anti-aliasing:
grayscale_antialiasing

GNOME Tweak Tool settings:
Gnome_antialiasing_settings

@astrolemonade
Copy link
Contributor

astrolemonade commented Jul 3, 2019 via email

@spinnau
Copy link

spinnau commented Jul 3, 2019

The theme used in the screenshots is powerlevel9k.

I have tried this on another computer, also with GNOME-Terminal 3.32.2 on GNOME desktop. The effect can be reproduced. With subpixel anti-aliasing the small gaps can be seen, but they are gone if the anti-aliasing is switched to grayscale. @ryanoasis so maybe this is just a rendering problem?

Both computers are running on arch linux with the same GNOME desktop version but with different graphics hardware and drivers. One computer uses nvidia drivers on X11 and a monitor with 110 ppi. The other computer runs intel graphics with modesetting driver on wayland and a monitor with 92 ppi.

@MIvanchev
Copy link

I have just hit this issue in 2021 (on Ubuntu MATE):

Image

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

@MIvanchev do you mean the faint line, circled yellow?

image

We would need exact font name (and if you self patched or where you did download it, to examine the exact same file), terminal used, terminal font settings,
Maybe you can try if turning antialiasing to 'greyscale' fixes it? (See Tweak tool some comments furter up.)

Edit: Note: Gnome Tweak tool updates the setting only after you close the tool!

@MIvanchev
Copy link

Hey @Finii, this line is exactly what I mean yes. This is Literation Mono size 12 downloaded directly from https://www.nerdfonts.com/. I use neovim-qt, default Gnome settings but changing them has no effect. Grayscale has no effect. The only thing that fixes this is disabling anti-aliasing completely.

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

I see it in Tilix:

image

But it is gone when greyscale.

image

  • Need to change to greyscale and close tweaks
  • Need to focus on tilix (which obviously only redraws if active)

Anyhow, that is just kind of hotfix for you, possibly.

Just found out #779 (comment)
Let's see (ponder) what we can do in that manner.

@MIvanchev
Copy link

MIvanchev commented Feb 7, 2022

@Finii Could you try the triangle characters back to back? Just tried again, grayscale has absolutely no effect.

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Can you copy and paste the chars, then I do not need to find out which comes first in your setup? The whole line if possible, as text.

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Cascadia Code again with extra neg. bearing on problematic (right in this case) side.

image

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

I use ordinary neovim running in tilix. Installed this Qt thing... where do I change the font 😬

If it does not work for you I bet it is some Qt font rendering blah... 🙄

@MIvanchev
Copy link

You change the font using :GuiFont in the ginit.vim file or in the editor itself. Try this text: 

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Hmm, in tilix (running neovim) the glyphs are too wide (as one also would have anticipated by the fontforge outline windows above (unchanged 2446 width 😒 )

image

Anyhow:
image

Do you use Literation Mono NF Mono instead?

@MIvanchev
Copy link

I think this error exists on any nerd font, just do :GuiFont! LiterationMono Nerd Font Mono:h12

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Hmm, I see it with LCD antialias:

image

but not with greyscale:

image

  • Change to greyscale
  • Close tweaks
  • restart neovim qt
  • reload text file
  • set GuiFont

Scaled up 400%:

image

(LCD antialias has these colored edges color fringes, i.e. left)

It's still there but very faint, can not see it without magnification.

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Oh, and I'm on X11 not Wayland, if that is a difference 🤔

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Hmm, our overlap code seems to be broken?

image

No negative bearing on left, but negative bearing on right.
Should be some overlap over the 'box' on both sides.

\me starts up editor

           if overlap != 0:
                overlap_width = self.font_dim['width'] * overlap
                if sym_attr['align'] == 'l':
                    x_align_distance -= overlap_width
                if sym_attr['align'] == 'r':
                    x_align_distance += overlap_width

            align_matrix = psMat.translate(x_align_distance, y_align_distance)
            self.sourceFont[currentSourceFontGlyph].transform(align_matrix)

            # Needed for setting 'advance width' on each glyph so they do not overlap,
            # also ensures the font is considered monospaced on Windows by setting the
            # same width for all character glyphs. This needs to be done for all glyphs,
            # even the ones that are empty and didn't go through the scaling operations.
            self.set_glyph_width_mono(self.sourceFont[currentSourceFontGlyph])

            # Ensure after horizontal adjustments and centering that the glyph
            # does not overlap the bearings (edges)
            self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])

😭 First we methodically overlap and then we remove the negative bearings...

@MIvanchev
Copy link

Hey, thanks for the extensive testing. Unfortunately I do still have it with. Even forcing grayscale with in fonts.conf doesn't change it. The shading along the edge is different but still extremely noticeable.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family" compare="eq">
      <string>LiterationMono Nerd Font Mono</string>
    </test>
    <edit name="rgba" mode="assign"><const>none</const></edit>
  </match>
</fontconfig>

I think I'm going to generate a bitmap grayscale font and work with that.

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Some years back we added the 'overlap' to avoid the color lines, the overlap being much smaller than Cascadia Code's.
But now it seems the overlap is broken. I will try this out and possible come up with a PR; will inform you.

It still might be a problem with Qt's font rendering (I do not trust anything Qt 😬) or how neovim-Qt does it. All the different terminal emulators have all their own opinions how to render fonts, now yet another idea ;)

I think monochrome antialias is not a solution anyhow, there is a reason we have LCD specific antialias ;)

@MIvanchev
Copy link

Thanks, I'm really grateful for your insights!!! Btw this is not only in Qt, every tool on the system has it. It's some GNOME / FreeType weirdness. I was quick to blame Qt as well.

Finii added a commit that referenced this issue Feb 7, 2022
[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

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

I guess this is solved now. Maybe you can check the font on your setup.
Can you self-patch from the PR or shall I put the font file somewhere to download?

@MIvanchev
Copy link

I can self-patch, will retest asap. Thank you so much btw!

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Homeoffice sei dank ;-)

@MIvanchev
Copy link

Allerdings :)) Das ist echt großartig.

@MIvanchev
Copy link

Current result with --complete:

Image

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

This looks like LiterationMono Nerd Font (non-Mono). The triangular things have double-width there.
*duh* it's written in your vim ini :-D

I did not check the overlap for the non-mono version 😬

Is it an improvement? I see faint lines. Do they bother? Maybe patch with 4% overlap 🙄

@MIvanchev
Copy link

Wait, what, it says mono in the name, I'm CONFUSED :D

@Finii
Copy link
Collaborator

Finii commented Feb 7, 2022

Literartion Mono Nerd Font (not mono)
Literartion Mono Nerd Font Mono (real mono)

naming is hard...

@MIvanchev
Copy link

--mono plus 4% overlap worked :)

Image

Finii added a commit that referenced this issue Jan 12, 2023
[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

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Finii added a commit that referenced this issue Jan 12, 2023
[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

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Finii added a commit that referenced this issue Jan 13, 2023
[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

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.