pop-os / cosmic-term

WIP COSMIC terminal emulator
GNU General Public License v3.0
301 stars 40 forks source link

Wrong color of ligatures under cursor #177

Open snaggen opened 2 months ago

snaggen commented 2 months ago

When you are placing your cursor on a ligature like the one created by == the whole ligature gets the inverted foreground color, but only half of the ligature gets an inverted background. This makes the text invisible, which is quite confusing sometimes.

The fix would be that only the part that gets the inverted background should also get the inverted foreground color.

bild

MoSal commented 2 months ago

If that ligature is a single glyph, then I think (haven't looked at that code for a while) what you propose would require glyph splitting support from the cosmic-text side, which would be quite the feature if a brave soul embarks on implementing it ;) I actually would have another use for it (line splitting in paragraphs if such a full-width ligature starts at num_cols - 1).

But does any shaping library have such a feature? If the answer is no, then there is probably a good reason for it.

It might be a little bit easier to invert the background in the other column, or maybe not render as a ligature (not sure about how to do the latter).

snaggen commented 2 months ago

Well I don't know if ligature are a single glyph or not, I would assume so. However, here is how it looks in wezterm for the characters != rendered as a ligature: bild

snaggen commented 2 months ago

Also, inverting the background for the whole ligature will not work, since then you will no longer know in what position you have the cursor. So, inverting only half of the ligature like in the wezterm screenshot is the way to do it.

jackpot51 commented 2 months ago

I'm fairly certain that other renderers basically color some portion of the glyph (based on the number of unicode characters it contains) if you ask it to color only part of it.

jackpot51 commented 2 months ago

Another thing we could do as a workaround is just split up the ligature if it has different attributes.

MoSal commented 2 months ago

Glyph splitting support would be great. Because in some cases, there is no ligature to split. Country flags (two single-width chars combining into a full-width flag) is an example I came across.* That example is extra fun because the noto font uses full-width glyphs for the country flag chars when they're not combining.

🇺 + 🇸 = 🇺🇸

* I'm interested in more examples if they exist (independently of the issue here).