-
Notifications
You must be signed in to change notification settings - Fork 1
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
magic width modification considered harmful #4
Comments
This was the one of the main reasons for creating this protocol in the first place: terminals want a way to display things like the pirate flag nicely without breaking backwards compatibility, and that's why there is a mode for it. Apps that expect widths to be calculated with the old wcwidth/wcswidth algorithm would simply not set mode ?2027, and everything should work exactly as it's always done. But if a terminal claims to be able to support mode ?2027, and an application requests that support, then they should be able to rely on the terminal honoring that request in a predictable manner. If a particular font doesn't support the pirate flag emoji then worst case you just display a question mark or whatever fallback you'd use for any other missing glyph. The key thing is that you use the correct width calculation so that the layout of the page doesn't break. If you don't think this is a good idea, then just don't support this mode, and carry on doing your own thing. |
OK, 2 points:
|
I didn't write the spec, and I'm not overly familiar with all the details, so I'm not the best person to answer these questions. However, regarding your second point, I would have thought a combination like If an application has requested mode But again I'm not an expert on this subject - hopefully somebody else will chime in here with a more authoritative answer. |
Having checked all emoji sequences, it seems that the issue could be resolved by two simple rules:
Both rules would need to be applied to any character sequence, regardless of whether it has an emoji definition, and regardless of whether it has a glyph in the current font. So the following resulting examples should be checked:
It's unclear whether additional variation selectors might affect width as recently discussed in https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/9. |
I've created an issue at https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/36. |
I've implemented this experimentally for mintty. Switching is done with DECSET 7769 for now. 2027 should not be used as it was in used by some terminas for something different. |
I think this is pretty bad. Why do you want to deviate from 2027? To me it seems to be quite well accepted by those who where involved already. Why changing then? This only creates friction. :( |
It seems this is actually your own fault. See mintty/mintty#1255 (comment),
Please list terminals that use 2027 for emoji width mode already. |
These are some that I'm aware of: Also looks like it's used in the following applications/libraries: |
Thank you. So I'll switch for the release. |
By the way, do you also have an overview which terminals implement auto-rewrap and which use 2028 for it? |
but that was fixed in January already. We have July. It's still quite an early stage (given the fact, that the ecosystem is moving slowly) EDIT: thanks for the summary, @j4james :) |
I'll support both mode settings for now as it's not yet clear whether implementations will be compatible. |
Several sections assume that width of a grapheme cluster can be modified in magic ways:
This is a serious problem in terminals. The traditional way for applications to know the width of its own output is based on the locale mechanism, addressed via function wcwidth/wcswidth. While this method has limitations, esp. in a remote login scenario, no other reliable method has been established.
So I suggest the reference for actual width assumption should be the width given by these functions, even taking some unpleasant visual consequences into account. How else could an application know how wide its output actually appears? Look at https://unicode.org/reports/tr51/#Display :
The width of the pirate flag 🏴☠️shown there depends on the actual availability of its emoji in the current environment (font or platform).
This information is inaccessible to a terminal application.
(The Unicode specification does not really address terminal display.)
So applications like editors would be confused and frequently display garbage.
The mintty terminal goes another way: It takes the locale width authoritative and adjusts emoji display to the width thus determined.
This can mean that single-width emojis appear squeezed into a single cell and that emoji sequences can take up to 8 character cells. For some compensation in style preference, mintty offers placement options to align, center, or expand the emojis to their consumed space.
While, as said above, this may not be pleasant, it is the only way I see to achieve consistent screen handling and avoid garbage caused by unforeseeable positioning. The only alternative would be that an application requests cursor position reports after every questionable grapheme output which would slow down screen output considerably.
Also in particular
contradicts traditional cursor behaviour and would result in unreliable position assumptions. Cursor position inside a multi-column glyhp needs to be maintained somehow. Output of text there would then break the previous glyph (also for non-emoji glyphs like East Asian).
The text was updated successfully, but these errors were encountered: