microsoft / terminal

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

Unicode Pawn does not display like other Unicode chess symbols #13110

Open paul-hansen opened 2 years ago

paul-hansen commented 2 years ago

Windows Terminal version

1.13.10984.0

Windows build number

10.0.22000.0

Other Software

No response

Steps to reproduce

Paste this Unicode character into your terminal ♟(U+265F) Source: https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode

Expected Behavior

I expected it to match the current foreground color of the terminal similar to the other chess related Unicode symbols.

Actual Behavior

The pawn is always purple. Here's a screenshot of my chess game output in the windows terminal: image I can change the foreground color for all the other pieces using ANSI color codes but the pawn is always purple.

zadjii-msft commented 2 years ago

a minimal repro

printf "White: \u2654 \u2655 \u2656 \u2657 \u2658 \u2659\nBlack: \u265a \u265b \u265c \u265d \u265e \u265f \n"

Looks like the black pawn is an emoji, when the others aren't.

I suspect this is because the chess characters aren't in Cascadia Code (or most fonts), dwrite looks up the glyph in some other font that does have it, and the emoji font shows up higher in the search list than wherever the other pieces are coming from. Hmm.

Might not be anything we can do here besides changing the font fallback order for glyphs (#2664)

zadjii-msft commented 2 years ago

See also #6864, but like the opposite. The black bawn is "emoji yes, emoji-presentation no", so it shouldn't be rendered by dwrite as an emoji, but it is. Hmm.

j4james commented 2 years ago

My understanding is that there are a number of glyphs that have both a text presentation and an emoji presentation, and you can use a variant selector to choose which style you want. They each have a default style though (when no variant selector is used), and in the case of the black pawn, the default style is meant to be text.

I'm sure I've seen a document somewhere that list all the default styles in a simple table, but the best I can find at the moment is this: https://www.unicode.org/emoji/charts/text-style.html

paul-hansen commented 2 years ago

I suspect this is because the chess characters aren't in Cascadia Code (or most fonts), dwrite looks up the glyph in some other font that does have it, and the emoji font shows up higher in the search list than wherever the other pieces are coming from.

That seems accurate, I confirmed it does use the font's symbol if you use a font that has the symbols. I found a font that has chess symbols using this page https://www.fontspace.com/unicode/char/265C-black-chess-rook image

The issue you linked would help a lot, enabling us to set it up the way we want on our own PCs. However it's not a great solution for if I wanted to distribute software that uses those symbols though. I would have to instruct all users on how to install a special font correctly if they are using Windows Terminal. Any ideas on how to address where the default is coming from?

If it was consistent and all the Unicode chess pieces were rendered as emoji, that would okay too. At least they would be usable together.

Seems like this isn't limited to Windows Terminal: Discord has a similar issue: image And in Chrome: image

I'm not sure if that means it's a Windows OS problem, or the best way to report that if it is. Maybe I should report it in the WinUI repo? https://github.com/microsoft/microsoft-ui-xaml Seems like they would probably just have to escalate it to whoever works on DirectWrite or something too though.

paul-hansen commented 2 years ago

My understanding is that there are a number of glyphs that have both a text presentation and an emoji presentation, and you can use a variant selector to choose which style you want. They each have a default style though (when no variant selector is used), and in the case of the black pawn, the default style is meant to be text.

I'm sure I've seen a document somewhere that list all the default styles in a simple table, but the best I can find at the moment is this: https://www.unicode.org/emoji/charts/text-style.html

Apparently U+FE00 - U+FE0F are supposed to be variant selectors which you put after the Unicode character you want to modify. I'm having a hard time finding documentation on which ones do what though. In my testing in WT, all of them just make the character double wide (which is how my chess board looks so square in the first screenshot)

According to https://stackoverflow.com/a/38452396/5399098 U-FE0E is supposed to force the text version. Black Pawn:♟️ Black Pawn with ︎:♟ White Pawn: ♙️ Doesn't seem to work on Github for me but you can copy it into the textbox on https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea and it works there for me. image

DHowett commented 2 years ago

Just driving by to say: this touches on #1472 and friends (#8000)!

lhecker commented 3 months ago

It seems we forgot to mention here that the latest Windows Terminal version now has a setting to disable colored Emojis: image

However, we still need to add support for handling VS-15 and VS-16 so that colored and uncolored Emojis can be mixed. That's a little bit more difficult unfortunately and currently not that high of a priority.