Treat emoji + VS16 sequences as double-width - #5262
Open
xhon-pelushi wants to merge 1 commit into
Open
Conversation
Some emojis, such as U+2764 ❤ (HEAVY BLACK HEART), U+1F5E1 🗡 (DAGGER KNIFE) and U+1F5FA 🗺 (WORLD MAP), are narrow by default (Emoji_Presentation=No) and only take on their double-width emoji form when immediately followed by U+FE0F VARIATION SELECTOR-16. WcWidth previously ignored this context and always reported them as width 1, so TerminalRenderer's font-width-mismatch correction would scale the naturally wide glyph down to fit a single narrow cell, producing the reported squished rendering. WcWidth gains a table of the 219 code points with Emoji=Yes but Emoji_Presentation=No (derived from Unicode 15's emoji-data.txt) and a lookahead-aware width(chars, index[, limit]) that reports width 2 for one of these code points immediately followed by VARIATION_SELECTOR_16. TerminalRow#setChar widens the column for such a sequence instead of treating the selector as an ordinary zero-width combining mark, and TerminalEmulator advances the cursor to match. TerminalRenderer measures the selector along with its base character so the glyph's natural width is detected and no longer scaled down. Fixes termux#5251
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Emoji=Yes/Emoji_Presentation=Nobases when immediately followed by U+FE0F.Fixes #5251
Test plan
./gradlew :terminal-emulator:test(139 tests, including new VS16 cases)terminal-viewcompile