microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.73k stars 8.33k forks source link

The ❤ heart emoji can overlap with other characters #18143

Closed ClaireCJS closed 1 week ago

ClaireCJS commented 1 week ago

Windows Terminal version

1.21.2911.0

Windows build number

10.0.19045.5011

Other Software

I'm just echoing characters to the console from my command line (TCC)

Steps to reproduce

In TCC:

    echo %@char[10084] %@repEAT[%@CHAR[10084],4]^ECHO 1234567890

In CMD:

    echo ❤ ❤❤❤❤

(but it is possible it is not encoded correctly here in the comment, as it is not rendered red. Grab the ones from the subject line instead, those appear rendered correctly. Maybe it makes no difference.)

Expected Behavior

I was expecting Image

Actual Behavior

What?!?!?! A ligature of hearts????

Is this intentional?

Is there a list of all the emoji ligatures? [I lost the ligature list and can't find it]

Do you accept user-contributed artwork of new emoji-combination-ligatures, if they are up to visual quality standards?

Image

ClaireCJS commented 1 week ago

Possible duplicate of #18145 if this is the reason you can also do this: Image

lhecker commented 1 week ago

There are 2 reasons this happens

  1. The ❤ emoji is this codepoint: https://codepoints.net/U+2764 As you can see there "It has no designated width in East Asian texts". Traditionally, this means that the terminal interprets it as a narrow character and so it only gets allocated 1 cell.
  2. There are so called "unqalified" and "fully qualified" emojis. The difference between the two is that unqualified ones can either be black & white or colored, and it's up to the text renderer to decide that. "fully qualified" emojis are those where the emoji codepoint is followed by either U+FE0E (= black & white) or U+FE0F (= colored), which tells the text renderer what to pick.

You're using U+2764 ❤ in its "unqualified" version. This means it gets 1 cell and it's up to the text renderer to decide how it should look like. Our text rasterizer (DirectWrite) uses color in that case. This way you end up with a colored emoji that gets only 1 cell and thus ends up overlapping surrounding glyphs/characters.

The solution is for you to use ❤️ (U+2764 U+FE0F) instead of ❤ (U+2764) and to use Windows Terminal 1.22 or later which has support for grapheme clusters (= can detect such pairs of U+FE0F).

Let me know if you have any other questions!

DHowett commented 1 week ago

FWIW, if it seems weird that they can overlap... this is the "social standard" way that other terminal emulators have chosen to render them as well. Apple's Terminal.app does the same.

The ability to trivially overlap glyphs is a prerequisite for proper rendering of Arabic, Devanagari, Sinhala and others. :)