Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Grapheme(e.g. graphemes containing zero width joiner) takes more width than it should to display in terminal #6323

Closed
glyh opened this issue Jun 1, 2023 · 8 comments
Labels

Comments

@glyh
Copy link

glyh commented Jun 1, 2023

Describe the bug
Grapheme takes too much width when displaying

To Reproduce
Steps to reproduce the behavior:

  1. type in "πŸ‘©β€πŸš’"
  2. note how it takes 4 char width(which is the width it requires if we consider graphemes separately and ignore the 0-width joiner) , but it should takes 2.

Screenshots

image

Environment details

kitty 0.28.1 created by Kovid Goyal
Linux arch 6.3.4-arch2-1 #1 SMP PREEMPT_DYNAMIC Mon, 29 May 2023 13:58:34 +0000 x86_64
Arch Linux 6.3.4-arch2-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/fish
Loaded config files:
  /home/lyh/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control yes
font_family          FiraCode Nerd Font
font_size            12.0
scrollback_pager     ['page']
shell                fish
Colors:
        background           #323232   
        color0               #252525   
        color1               #be7472   
        color10              #97bb98   
        color11              #fefdbc   
        color12              #9fbdde   
        color13              #989abc   
        color14              #6fbbbc   
        color15              #feffff   
        color2               #709772   
        color3               #989772   
        color4               #7199bc   
        color5               #727399   
        color6               #719899   
        color7               #7f7f7f   
        color8               #555555   
        color9               #ff9900   
        cursor               #c7c7c7   
        cursor_text_color    #feffff   
        foreground           #c8c8c8   
        selection_background #c1ddff   
        selection_foreground #3e3e3e   

Important environment variables seen by the kitty process:
        PATH                                /home/lyh/Binaries:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/lyh/.local/bin:/ho
me/lyh/.yarn/bin:/home/lyh/.cargo/bin:/home/lyh/.gem/ruby/3.0.0/bin:/home/lyh/.local/share/racket/8.9/bin:/usr/bin/site_perl:/u
sr/bin/vendor_perl:/usr/bin/core_perl
        LANG                                en_US.UTF-8
        VISUAL                              nvim
        EDITOR                              nvim
        SHELL                               /bin/fish
        DISPLAY                             :0
        WAYLAND_DISPLAY                     wayland-1
        USER                                lyh
        XCURSOR_SIZE                        24
        XDG_CONFIG_HOME                     /home/lyh/.config
        XDG_USER_CONFIG_DIR                 /home/lyh/.config
        XDG_SEAT                            seat0
        XDG_SESSION_TYPE                    wayland
        XDG_CURRENT_DESKTOP                 sway
        XDG_SESSION_CLASS                   user
        XDG_VTNR                            1
        XDG_SESSION_ID                      1
        XDG_RUNTIME_DIR                     /run/user/1000



Additional context

Can reproduce with no config.

@glyh glyh added the bug label Jun 1, 2023
@kovidgoyal
Copy link
Owner

U+1f469 is supposed to have emoji presentation by default as per the
unicode standard. If you dont want it to have emoji presentation follow
it up with the text variation selector U+fe0e

@glyh
Copy link
Author

glyh commented Jun 1, 2023

@kovidgoyal How is your comment related to my issue? I do want it to have emoji printed but it's taking up width of 2 characters in the terminal.

@kovidgoyal
Copy link
Owner

Emojis are supposed to have width two.

@glyh
Copy link
Author

glyh commented Jun 1, 2023

Okay my bad, when I say two it actually takes up 4 char width:
image

And for example this case it takes 6 char width:
image

There's no space when you actually see the space. It's just kitty thought it takes more than 2 char width when it doesn't.

@kovidgoyal
Copy link
Owner

Does not reproduce for me.
screenshot

@glyh
Copy link
Author

glyh commented Jun 1, 2023

Can you try this?

print('|' + b'\xf0\x9f\x91\xa9\xe2\x80\x8d\xf0\x9f\x9a\x92'.decode('utf-8') + '|')

@kovidgoyal
Copy link
Owner

That's not a single codepoint. Thats two emojis joined with a zero width
joiner. The combination is rendered as a single emoji but zero width
joiners are not supported in kitty and indeed most terminal programs.

dup of #3810

@glyh glyh changed the title Grapheme takes too much width when displaying Extended Grapheme(e.g. graphemes containing zero width joiner) takes more width than it should to display in terminal Jun 1, 2023
@glyh
Copy link
Author

glyh commented Jun 1, 2023

Thank you for the clarification and sorry for the confusion in my description on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants