-
-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Emoji and variation selectors (VS15 / VS16) #997
Comments
wezterm defers to harfbuzz for shaping, so I'm not sure what more is needed. |
I am sorry, I do not know your source code internals. But do you forward all the necessary codepoints? I am sorry if I'm giving superfluous information here (apologizing ahead of time :) ), but maybe U+FE0F is not landing in the same grid cell as U+00A9 for example? echo -ne "\u00A9\uFE0F" On top of that, U+00A9 should be rendered using regular font, but U+00A9 followed by a U+FE0F represents one grapheme cluster whose emoji presentation is "emoji" (i.e. not "text") and therefore should use the emoji font instead of the non-emoji font (e.g. regular). Have a look here maybe for a hopefully self-explaining illustration: |
These modifiers have the effect of forcing us to consider the grapheme as being either a single cell (VS15) or two cells (VS16) in the terminal model. These don't affect font choice as wezterm doesn't know whether a given font in the fallback has a textual vs. an emoji version of a given glyph, or whether a later font in the fallback has one or the other because we can't know until we fall back, and that has a very high cost--we perform fallback asynchronously in another thread because of its high cost. Depending on the selected glyph, it may or may not render as double wide. refs: #997
If the font supports both text and emoji presentation and can switch between them internally (e.g. using ligatures) then Hard buzz would help. I haven't seen any fonts do this, though, most systems handle it by switching fonts based on what presentation is required. |
Exactly. This is what I was trying to say. And it look like wezterm isn't doing that. Or did i miss something? |
From the commit message in 76b72e4:
AFAIK, there isn't a concept of "this font is a text font" or "this font is an emoji presentation font" which means that a dedicated emoji font fallback list option would need to be introduced for this in order for wezterm to choose a font to match the selected presentation. I'm not sure how I feel about that at the moment, but I'll give it some thought. |
I think heuristics can be used to detects color fonts, e,g. using https://harfbuzz.github.io/harfbuzz-hb-ot-color.html#hb-ot-color-has-layers, https://harfbuzz.github.io/harfbuzz-hb-ot-color.html#hb-ot-color-has-png, etc. and assume these have emoji presentation by default. Since there are not that many emoji fonts, a list of known emoji font names can be used in addition to/instead of such checks. |
Make a distinction between default and selected presentation, and account for that in the cell width. Add a method to the cell that returns the effective presentation. refs: #997
This should give the shaper a better chance at using text presentation in a run that mixes emoji with text and/or uses presentation selectors. It also exposes the presentation property to the shaper so that it could potentially adjust its fallback strategy. However, it doesn't do that here. refs: #997
This commit annotates fonts with a boolean that indicates whether we think it contains glyphs with emoji presentation, and then passes the cluster.presentation field down to the shaper. If the presentation doesn't match the current font in the fallback, then it will be skipped until we exhaust its options. `wezterm ls-fonts` also shows whether we think a font has emoji presentation. refs: #997
as of 0866e5d the behavior is now:
|
Hey @wez thanks for also taking care of VS15/VS16, but I had some findings -> while looking for terminals that do support VS15/VS16 (again), I was also trying your TE (again :) ). echo -e "\U0001f600\ufe0e" yields to the following notification
and that visual: but should look like (gnome-terminal screenshot): I did not look into your source code, but maybe there is no grapheme cluster segmentation happening and that's why this grapheme cluster) is split and passed into two separate (p.s.: I actually came here to see what cell width your apply to VS15 overrides, as I think there is no common consensus in the TE dev community.) |
I think that notification is showing the wrong information (it infers the grapheme from something that's lost information on its journey to harfbuzz). I think what's really happening is that the presentation mode is preventing wezterm from finding any matching font. I'll dig into that. Regarding your question about widths, the logic I settled on is:
|
The introduction of the Emoji vs Text VS processing means that we might in some cases not find a glyph with the requested presentation. In that case, we'd rather show the emoji presentation glyph than none at all, so we'll retry fallback processing with unspecified presentation. refs: #997
@christianparpart FWIW, I get the same results as gnome terminal when I I pushed a commit that avoids claiming that VS15 or VS16 are missing glyphs; that was just a simplistic oversight in the error reporting path. That same commit will make a second pass through the fallback list and ignore the selected presentation so that in the case where we couldn't find the glyph in the requested presentation, we'll accept any presentation. We'll still proceed to try loading fallbacks from the system and re-evaluate once they load, so hopefully that makes things look a bit better for @4cm4k1 |
@wez Pulled down the newly built nightly; LGTM! Thanks. |
Might I make an observation in that whether a colour emoji presentation is a narrow or wide one does depend on (I think) the version of Unicode that it it was introduced in. You may find https://github.com/ridiculousfish/widecharwidth/ of interest - which is keep up to date (unlike Markus Kuhn's |
This is a fairly far-reaching commit. The idea is: * Introduce a unicode_version config that specifies the default level of unicode conformance for each newly created Terminal (each Pane) * The unicode_version is passed down to the `grapheme_column_width` function which interprets the width based on the version * `Cell` records the width so that later calculations don't need to know the unicode version In a subsequent diff, I will introduce an escape sequence that allows setting/pushing/popping the unicode version so that it can be overridden via eg: a shell alias prior to launching an application that uses a different version of unicode from the default. This approach allows output from multiple applications with differing understanding of unicode to coexist on the same screen a little more sanely. Note that the default `unicode_version` is set to 9, which means that emoji presentation selectors are now by-default ignored. This was selected to better match the level of support in widely deployed applications. I expect to raise that default version in the future. Also worth noting: there are a number of callers of `unicode_column_width` in things like overlays and lua helper functions that pass `None` for the unicode version: these will assume the latest known-to-wezterm/termwiz version of unicode to be desired. If those overlays do things with emoji presentation selectors, then there may be some alignment artifacts. That can be tackled in a follow up commit. refs: #1231 refs: #997
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
i see you are supporting also ZWJ emoji, so it seems.
Maybe you also want to support U+FE0E and U+FE0F VS15/VS16 variation selectors?
I just checked, Kitty also seems to do that, so I'll now allow width changes to.
There is only a little number of TEs doing proper text shaping but I think the list is slowly growing and thus, maybe you want to consider supporting VS15/16 too.
The text was updated successfully, but these errors were encountered: