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

Draw undercurls in addition to underdots #42

Open
jacobmischka opened this issue Dec 18, 2022 · 3 comments
Open

Draw undercurls in addition to underdots #42

jacobmischka opened this issue Dec 18, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@jacobmischka
Copy link

For reasons as laid out in #14, I understand why underdots are being rendered currently, but as mentioned in that issue it would be nice to be able to render undercurls again instead.

It would be nice to be able to subscribe to a tracking issue for that, so I wanted to open this.

Thanks!

@baco
Copy link

baco commented Dec 21, 2022

Reviewing other GTK4 apps (GNOME's Text-Editor and Builder), when underlining spelling mistakes, the GTK4 decoration is a dotted line. It seems de default has changed from curly line to a dotted one.

Some remarks, the dotted underline on either of the GTK4 applications mentioned here are significantly thinner than the dotted underline in Neovim-gtk, for the same font size (tested with Iosevka Curly Slab 8.4pts).

@jacobmischka, perhaps a good compromise would be to have a flag or setting to re-enable the undercurl instead of a dotted underline, but it looks to me like the new behavior is the GTK4 default.

@Lyude
Copy link
Owner

Lyude commented Dec 25, 2022

Reviewing other GTK4 apps (GNOME's Text-Editor and Builder), when underlining spelling mistakes, the GTK4 decoration is a dotted line. It seems de default has changed from curly line to a dotted one.

Some remarks, the dotted underline on either of the GTK4 applications mentioned here are significantly thinner than the dotted underline in Neovim-gtk, for the same font size (tested with Iosevka Curly Slab 8.4pts).

Yeah - I didn't take the time to dig through GTK4's rendering code to actually figure out what exactly they're doing with the font metrics to determine the undercurl size. I'm totally happy to accept patches to fix this

@jacobmischka, perhaps a good compromise would be to have a flag or setting to re-enable the undercurl instead of a dotted underline, but it looks to me like the new behavior is the GTK4 default.

I think we still want to support both actually, it's less about GTK4's decision and the fact that nvim does actually have two formatting options for both undercurl and underdotted (they're mentioned in :help ui-event-hl_attr_define). Ideally, I'd like to move undercurl back to something like what we had before - and then use underdotting for the actual underdotted effect. This does have the limitation that we won't be able to do this effect in situations where we're using native GTK4 widgets to display text (like documentation in the PopupMenu overlay), but that's a small enough detail I'm willing to sacrifice (maybe I could submit patches to GTK4's PangoRenderer to add an additional undercurl mode someday while maintaining underdot default to fix that, if I ever get the motivation to).

@Lyude
Copy link
Owner

Lyude commented Dec 29, 2022

Ok cool, so I took a look at this again today and it seems like I actually got almost everything right after the initial 4.6+ fix. Seems like the only two things I was missing:

  • The diameter of the circles should be equal to underline_thickness
  • We should round the y coordinate we start on to the nearest integer, so that at smaller sizes the dots still look perfectly consistent and don't end up with a different color as a result of fractional coordinates.

This gives us something that imho, looks far nicer and more legible:

image

Ironically, because I still didn't dig any further in GTK4's method for drawing underdots I think I actually came up with something that looks a bit nicer then GTK4's defaults (or at least, it certainly looks better then the underdots I see in gtk 4.6's inspector. Maybe 4.8+ look better though?). So I think I'm going to go with this, and look into whether the gtk folks would be interested in me porting this to GTK4 so everyone can have nice underdots.

Lyude added a commit that referenced this issue Dec 29, 2022
This addresses some of the issues that were mentioned in #42 regarding the
underdot effect looking too large. It turns out that we can fix this pretty
nicely by using the underline_thickness metric as the circle diameter, and
round the y coordinate down.
Lyude added a commit that referenced this issue Dec 30, 2022
This addresses some of the issues that were mentioned in #42 regarding the
underdot effect looking too large. It turns out that we can fix this pretty
nicely by using the underline_thickness metric as the circle diameter, and
round the y coordinate down.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants