[vim/vim] return 2 for emoji width in the 0x2300-0x1f000 range if ambw=double (#2074)

82 views
Skip to first unread message

mattn

unread,
Sep 9, 2017, 10:49:11 AM9/9/17
to vim/vim, Subscribed

On current implementation, emoji characters in range 0x2300-0x1f000 is not listed which return 2 from utf_char2cells(). I know this is compatible issue.

#665

3848e00

6a08454

Now, I'm thinking that user who got the compatible issue should set ambiwidth=single. So I suggest to return 2 for the emoji characters in the range 0x2300-0x1f000, if ambiwidth=double.

If you don't like this, I can make patch to add new option or detect locale string is CJK.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/2074

Commit Summary

  • return 2 for emoji width in the 2300-1f000 range if ambw=double

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Bram Moolenaar

unread,
Sep 9, 2017, 1:48:34 PM9/9/17
to vim/vim, Subscribed

Yaruhiro wrote:

> On current implementation, emoji characters in range 0x2300-0x1f000 is
> not listed which return 2 from utf_char2cells(). I know this is
> compatible issue.
>
> https://github.com/vim/vim/issues/665
>
> https://github.com/vim/vim/commit/3848e00
>
> https://github.com/vim/vim/commit/6a08454

>
> Now, I'm thinking that user who got the compatible issue should set
> ambiwidth=single. So I suggest to return 2 for the emoji characters in
> the range 0x2300-0x1f000, if ambiwidth=double.
>
> If you don't like this, I can make patch to add new option or detect
> locale string is CJK.

I get very confused about the 'emoji' option. The docs say:

When on all Unicode emoji characters are considered to be full width.

But then it only applies to the characters in emoji_width, not
emoji_all. Why doesn't it use emoji_all?

Then utf_ambiguous_width() returns true for all emoji characters, but
when 'amibwidth' is "double" this isn't taken into account.

So what should be the proper behavior? Are there any characters in
emoji_all that are always single width? The utf_ambiguous_width() needs
to be ajusted.


--
A fool learns from his mistakes, a wise man from someone else's.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

mattn

unread,
Sep 10, 2017, 9:11:43 PM9/10/17
to vim/vim, Subscribed

I get very confused about the 'emoji' option. The docs say:

When on all Unicode emoji characters are considered to be full width.

But then it only applies to the characters in emoji_width, not
emoji_all. Why doesn't it use emoji_all?

Then utf_ambiguous_width() returns true for all emoji characters, but
when 'amibwidth' is "double" this isn't taken into account.

Please remember this thread on mailing list.

https://groups.google.com/forum/#!searchin/vim_dev/Arrow$20characters$20shouldn$27t$20be$20wide%7Csort:relevance/vim_dev/fu0ZZIx5gjk/2-MOLugwGgAJ

6a08454

So what should be the proper behavior? Are there any characters in emoji_all that are always single width? The utf_ambiguous_width() needs to be ajusted.

Some of terminal still not be fixed to show emoji as square box. On such terminal, is drawn as narrow width. There are two types of terminal. One of them draw ↖ as narrow, Other one draw ↖ as wide. So we should provide way to switch them.

I thought for the way to fix this issue. And I guess the user who expect narrow width for ↖ should set ambiwidth=single.

mattn

unread,
Sep 10, 2017, 9:13:45 PM9/10/17
to vim/vim, Subscribed

However, I can not make sure that there are no side effects from my suggestion. So, if you do not like this change, I can prepare another option.

Bram Moolenaar

unread,
Sep 11, 2017, 4:01:45 PM9/11/17
to vim/vim, Subscribed

Yasuhiro wrote:

> > I get very confused about the 'emoji' option. The docs say:
> >
> > When on all Unicode emoji characters are considered to be full width.
> >
> > But then it only applies to the characters in emoji_width, not
> > emoji_all. Why doesn't it use emoji_all?
> >
> > Then utf_ambiguous_width() returns true for all emoji characters, but
> > when 'amibwidth' is "double" this isn't taken into account.
>
> Please remember this thread on mailing list.
>
> https://groups.google.com/forum/#!searchin/vim_dev/Arrow$20characters$20shouldn$27t$20be$20wide%7Csort:relevance/vim_dev/fu0ZZIx5gjk/2-MOLugwGgAJ

That discussion was open ended. And the help for the 'emoji' option is
wrong, it only applies to the characters in "emoji_width".
And the comment for it says "Emoji characters that don't have ambiguous
or double width". Even though they are double width in the emoji
table...

> https://github.com/vim/vim/commit/6a08454

>
> > So what should be the proper behavior? Are there any characters in emoji_all that are always single width? The utf_ambiguous_width() needs to be ajusted.
>
> Some of terminal still not be fixed to show emoji as square box. On
> such terminal, `↖` is drawn as narrow width. There are two types of
> terminal. One of them draw ↖ as narrow, Other one draw ↖ as wide. So
> we should provide way to switch them.
>
> I thought for the way to fix this issue. And I guess the user who
> expect narrow width for ↖ should set ambiwidth=single.

No, 'ambiwidth' has no relattion to emoji characters. It's for another
group of characters.

Is it right to say that all emoji characters should be double width, but
in some fonts a subset is single width?


--
To be rich is not the end, but only a change of worries.


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

mattn

unread,
Sep 11, 2017, 8:57:10 PM9/11/17
to vim/vim, Subscribed

Is it right to say that all emoji characters should be double width, but
in some fonts a subset is single width?

Sorry, my idea is bad. you are right. So it can't define with single option emoji. How about following ideas to correct this issue.

new function to define widths

let cells = {
\ "2139",
\ "2194-2199",
\ ...
\}
call setwcwidth(cells)

load cell-width list file

:loadwcwidthfile /path/to/wcwidth.txt

Should be list as same as above func.

override wcwidth by dll/so

int
my_wcwidth(int c) {
  return /* my custom width */
}

or

int
my_wcwidth(const char fontname, int c) {
  return /* my custom width */
}

Bram Moolenaar

unread,
Sep 27, 2019, 10:02:56 AM9/27/19
to vim/vim, Subscribed

Is this PR going to be worked on or shall we close it?

mattn

unread,
Sep 30, 2019, 5:25:43 AM9/30/19
to vim/vim, Subscribed

I want still working on this.

Bram Moolenaar

unread,
Jun 10, 2020, 2:28:48 PM6/10/20
to vim/vim, Subscribed

There is no progress on this, and also I don't see any issues being reported for emoji's. Therefore closing this. If you do have a known problem, please explain.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Jun 10, 2020, 2:28:54 PM6/10/20
to vim/vim, Subscribed

Closed #2074.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

mattn

unread,
May 17, 2022, 8:17:30 PM5/17/22
to vim/vim, Subscribed

Ref: 08aac3c


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/2074/c1129438375@github.com>

Reply all
Reply to author
Forward
0 new messages