Skip to content

GTK4(font): fix letterspacing, signcol seams - #21013

Open
dezza wants to merge 3 commits into
vim:masterfrom
dezza:fix-gtk4-font-spacing-signcol-seams
Open

GTK4(font): fix letterspacing, signcol seams#21013
dezza wants to merge 3 commits into
vim:masterfrom
dezza:fix-gtk4-font-spacing-signcol-seams

Conversation

@dezza

@dezza dezza commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Problem:

  • Fonts do not account for letter spacing (:help 'linespace' is what vim calls it).
  • Sign column has seams between lines.

Solution:

  • Font: Round char with nearest pixel
  • Signs: Overlap adjacent row nodes by one pixel.

c158acf round char w nearest px

c158acf Overlap adjacent row nodes by one pixel.

GSK renderer rounding seems to add 1px (not sure).

Possibly related: https://blogs.gnome.org/gtk/2026/05/28/snapping/
author responded in irc with:

<Company> dza: but if you draw backgrounds with tiles of adjacent color/texture/whatever nodes, then you need snapping to avoid seams

(trying gtk_snapshot_set_snap after gtk 4.24)

Fixes: #21002

dezza added 2 commits August 11, 2026 22:07
Overlap adjacent row nodes by one pixel.

GSK renderer rounding seems to add 1px.

Possibly relevant:
https://blogs.gnome.org/gtk/2026/05/28/snapping/
@dezza dezza changed the title gtk4(font): gtk4(font): fix letterspacing, signcol seams Aug 11, 2026
@dezza

dezza commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@64-bitman please check if you see anything off in your view. I think my assessment of the custom narrow letterspacing/lineheight was correct - it should not affect your font much if correct.. If you preferred old look go change settings.

Comment thread src/gui_gtk4_da.c Outdated
GSK_SCALING_FILTER_NEAREST);
&GRAPHENE_RECT_INIT(FILL_X(0), FILL_Y(row),
(da->n_cols + bleed) * gui.char_width, gui.char_height + bleed),
GSK_SCALING_FILTER_TRILINEAR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it changed to trilinear? I used nearest to prevent blurring/antialiasing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I mean
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, my mistake - I thought I had removed that.

@64-bitman

Copy link
Copy Markdown
Contributor

I did not notice anything significant visually, so if it fixed your issue, then this looks good

@dezza

dezza commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@64-bitman I tested with some edgy set linespace=7 val and setting back again. My findings are;

  • gtk4 seems to add overall height between a total span of num of rows

.. but otherwise the dimensions look identical.

I attribute that to accumulating linear dpi scaling differences possibly also why my second observation cmdheight almost rounded up to a "row" of extra space in the bottom.

guioptions+=k is snapping to rows in gtk3, but not on gtk4 (freeform resize no snapping except internal shell) - possibly another issue.

Overall I think it looks proper now.

@dezza
dezza marked this pull request as ready for review August 11, 2026 21:00
@64-bitman

64-bitman commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

guioptions+=k is snapping to rows in gtk3, but not on gtk4 (freeform resize no snapping except internal shell) - possibly another issue.

If you are talking about resizing the window being able to snap to discrete rows, that is not possible in GTK4 (nor Wayland if I believe as of now).

@dezza dezza changed the title gtk4(font): fix letterspacing, signcol seams GTK4(font): fix letterspacing, signcol seams Aug 12, 2026
@chrisbra

Copy link
Copy Markdown
Member

@64-bitman okay with you?

I don't quite understand the code, so if it fixes the blurry rendering then it is fine with me. But one thing I don't follow: according to the comment bleed means to extend by one cell to the right, but you are now adding bleed also to the height? But those are two unrelated things, no?

@64-bitman

64-bitman commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@64-bitman okay with you?

I don't quite understand the code, so if it fixes the blurry rendering then it is fine with me. But one thing I don't follow: according to the comment bleed means to extend by one cell to the right, but you are now adding bleed also to the height? But those are two unrelated things, no?

It looks like it addresses this issue

GSK renderer rounding seems to add 1px (not sure).

I think the issue is dependent on the monitor resolution I'm guessing. @dezza is it necessary to fix your issue? Thanks

@dezza

dezza commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@chrisbra
Font:
Old code rounded up by default, causing extra spacing. New rounds to nearest pixel, avoiding extra spacing between letters and respects font defaults.

Signcol:
short: gtk4.24 introduce snapping to grid, addresses issues exactly like these as confirmed by one of the leading maintainers.

My fix shifts it a single logical unit (its not px, it maps to the devices scaling).


#21043 added as reminder for GTK4.24 (addresses the signcol temporary fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GTK4: letterspacing, signscolumn off

3 participants