glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ligature support

musjj opened this issue · comments

commented

It would be nice if ligature can be supported. I'm using JetBrainsMono and ligatures work just fine on GitHub code blocks. But it's not working inside firenvim.

I'm not sure if this is possible to do in a generic and efficient way for Firenvim. Firenvim has no actual knowledge of the font being used and I don't know of any canvas APIs that would check if a pair of characters would be rendered with ligatures. The only solution I can think of is to render each pair of characters first "normally" and then twice by changing the second character of the pair and comparing whether the results are pixel-for-pixel identical.
It also asks some interesting questions about what neovim highlights should be used to render ligatures when the underlying cells have different highlight ids.

I don't know about the Canvas interface issues. Just a couple random thoughts even though I don't feel any need for this personally...

  • You'll probably need to bundle and call out to an actual shaping engine to get this right: for example Harfbuzz can now be compiled to WASM.
  • As for syntax highlighting issues, I'm guessing you never want to ligature across a highlight group boundary.
  • There are other NeoVIM interfaces that support ligatures, for example Neovide. It is probably worth reviewing their implementations.