zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.57k stars 3.04k forks source link

Some emojis are replaced with a substituted character #16002

Open brandondrew opened 3 months ago

brandondrew commented 3 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Although there are a few other bug reports related to emojis, none appear to describe the behavior I'm experiencing.

Most emojis display just as expected in Zed, but every once in a while I run into one that fails to appear correctly. In order to isolate the problem--whether it occurs on insertion or display--I created a file in BBEdit, which does not have the same problem as Zed. I inserted 2 emojis in BBEdit and then opened it in Zed, and found Zed displayed it exactly as it does when inserting the same emoji into Zed, so the problem is related to display of that emoji and not insertion. I added a single lower-case 'x' in Zed and saved the file to see if Zed would corrupt it by changing the emoji character it could not display correctly. It did not. The file appeared in BBEdit the same except that the lowercase x was added.

Steps to reproduce the problem:

  1. create a file in BBEdit and add the red ❌ emoji (as well as others if you want);
  2. open the file in Zed and notice that the emoji is replaced with a different character;
  3. if you want to prove that Zed is only having problems with display, add characters and open the file again in BBEdit.
image

Environment

Zed: v0.147.2 (Zed) OS: macOS 14.5.0 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

No response

JunkuiZhang commented 3 months ago

Can not reproduce on my Mac, I copied and pasted ❌ from your description:

截屏2024-08-12 00 49 09
JunkuiZhang commented 3 months ago

Would you mind sharing your emoji.txt file?

brandondrew commented 2 months ago

Here it is:

emoji.txt

brandondrew commented 2 months ago

Can not reproduce on my Mac

I'm on macOS 14.5 (23F79)... what version are you on?

JunkuiZhang commented 2 months ago

I'm on macOS 14.5 (23F79)... what version are you on?

Same OS version, but I'm on the latest main branch zed build. I still can not reproduce this issue:

截屏2024-08-12 18 46 02
dcontiveros commented 2 months ago

I just reproduced this. The rendering depends on the context. Most text editors handle a majority of the subset of emojis. However, Zed does choke on crossmark. Reference the attached screenshot. I have also included a test file.

ss

test.txt

Edits:

  1. On 14.6.1 (23G93)
  2. Zed Preview 0.149.0
JunkuiZhang commented 2 months ago

Still can't reproduce on my end, this is so strange.

截屏2024-08-15 13 31 10
dcontiveros commented 2 months ago

@JunkuiZhang what is the font in your settings.json?

JunkuiZhang commented 2 months ago

@JunkuiZhang what is the font in your settings.json?

Arial

https://github.com/user-attachments/assets/343d0ebe-f5bc-458e-a9cc-9e6d43d6a1e3

dcontiveros commented 2 months ago

I've reproduced the problem. It appears to be an issue when using Zed Mono as the font.

https://github.com/user-attachments/assets/68e8eff1-5d12-4609-a5de-63c03760ef68

Using Andale Mono results in the proper rendering. I'll compile a list of commonly used fonts that don't work. Quick testing shows Source Code Pro works for me, but I would need to test more used fonts.

brandondrew commented 2 months ago

@JunkuiZhang what is the font in your settings.json?

Arial

I never ever ever ever use Arial

😂

brandondrew commented 2 months ago

For me even Andale Mono fails. (I was previously using the default font, which I think changed from Zed Mono to some IBM font recently.)

image
brandondrew commented 2 months ago

Arial fails too 😰

dcontiveros commented 2 months ago

For me even Andale Mono fails. (I was previously using the default font, which I think changed from Zed Mono to some IBM font recently.)

image

This is a different option. Try buffer font option.

brandondrew commented 2 months ago

Got it!

image
dcontiveros commented 2 months ago

I believe this needs to be classified as an issue with Zed Mono. This isn't the only font that is afflicted. I am partial to Iosevka and have seen this issue as well.

brandondrew commented 2 months ago

@dcontiveros If it afflicts multiple fonts, then are you sure it is a flaw in all of those fonts?

JunkuiZhang commented 2 months ago

@dcontiveros If it afflicts multiple fonts, then are you sure it is a flaw in all of those fonts?

The codepoint 274C, which represents the character , is handled by Zed Plex Mono:

Screenshot 2024-08-16 13 01 24

Therefore, the glyph display issue is a problem with the font, not with Zed. If a font like Arial, which does not include this codepoint, is used, Zed will fallback to CoreText for rendering the character correctly.

dcontiveros commented 2 months ago

Yes I figured this would most likely be a font issue vs. drawing. Emoji's are tough, especially in terminals. Any chance we can get a change on Zed Mono ?

JunkuiZhang commented 2 months ago

Yes I figured this would most likely be a font issue vs. drawing. Emoji's are tough, especially in terminals. Any chance we can get a change on Zed Mono ?

Yes, simply deleting that codepoint can work, here is a quick demo, I deleted that glyph from Zed Plex Mono:

截屏2024-08-16 14 15 24

cc @notpeter Since there are some issue with Zed Plex Mono already in #15542, so I guess maybe could open an issue for the font?

notpeter commented 2 months ago

Yeah, I don't know if the process for creating Zed Plex is documented/automated. @danilo-leal @iamnbutler