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
Ligatures are drawn at wrong character offset #2539
Comments
Yup that looks wrong. Let me take a look |
Weirdly I cant reproduce this issue on current main. Can you try building from main? |
actually i suspect this might be a bug with how swash handles ligatures from the most recent update to monaspace. Im running the initial release of the font which may explain why im not able to reproduce it. I will update my fonts tomorrow and try again. Should be straight forward to open an upstream issue in swash if i can confirm that that is the issue. |
It still happens when I build neovide from source. |
Ok I have confirmed. This is due to the way that ligatures are rendered in the most recent version of monaspace. The v1.000 release of the font does not have this issue, so I recommend installing that version for now. In the meantime, I will report the issue to swash (the crate we use to shape text) to see about getting it fixed upstream. |
Ok I've made a minimal repro that just uses swash and discovered that this issue is on our side after all. Neovim expects us to render characters on a grid by unicode grapheme. We store the expected grid position in the userdata that we pass to swash when shaping. So effectively the only thing we are depending on swash for in terms of shaping is figuring out which graphemes to combine into which glyphs. This is fundamentally a tradeoff. On the one hand, this causes neovide to render much closer to how terminal nvim would. Each character is drawn exactly on the grid. On the other, its incorrect in some cases for more advanced usages of the font rendering rewrite rules. Monaspace pushes those rules to the limit, so we run into these issues. An example of the kind of problem this approach avoids is that if you render the text exactly how the shaper expects, it is very easy to get offset from the strict grid for long runs of text. The current text renderer was arrived at to avoid that. I will need to think about the problem a bit to figure out what the best route forward is. Its not clear to me how to both strictly follow the grid, and position ligatured glyphs correctly |
Ignore that, my mistake |
This time I think I got it. While Monaspace does this It might be possible to support this in combination with a grid, since Wezterm for example does it. But otherwise, one of the goals of the fractional grid size PR was to support variable size fonts, and let the shaper control the horizontal positioning. That would solve this issue as well, but it's not that easy to implement, since we need a go from a character position to grid position to support mouse clicks, for example, and the other way around to render the mouse cursor. |
Describe the bug
I am using the font Monaspace Neon 13 with all ligatures enabled. This text:
should be displayed as follows (this screenshot is from TextEdit):
But Neovide displays it like so:
To Reproduce
Steps to reproduce the behavior:
config.toml
to use Monaspace Neon and enable ligatures. Here is myconfig.toml
:neovide
and enter the test text:a//a b==b c->c
Expected behavior
The display should match the TextEdit screenshot above. Instead, as shown in the Neovide screenshot above, each ligature is drawn starting one character position to the left of where it should be drawn.
Desktop (please complete the following information):
Please run
neovide --log
and paste the contents of the.log
file created in the current directory here:neovide_rCURRENT.log
The text was updated successfully, but these errors were encountered: