Update grapheme cluster width calculation#837
Merged
Conversation
Width of NonspacingMark and EnclosingMark is 0 Width of char just after ZeroWidthJoiner is 0 Width of Hangul GraphemeClusterBreak=V,T are 0 because there should be preceding L or LV
959cbad to
99dc2a3
Compare
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.
Implemented rules
Width of NonspacingMark and EnclosingMark is 0
Width of char just after ZeroWidthJoiner is 0
Width of Hangul GraphemeClusterBreak=V,T are 0 because there should be preceding L or LV
Other chars: sum of east asian width for each characters
Relation with grapheme cluster break rules
GB1 - GB5
Not related to width calculation
GB6, GB7, GB8
LVLVTare NFC normalized style.L+V,L+V+Tare NFD normalized style.East asian width of
LLVLVTis 2.L+VL+V+Tshould be 2-width, so treatVandTas zero-width.Width of standalone
Vand standaloneTvaries over terminal emulators (0 or 1)Width of
L+V+V+T+T,L+V+Tthat has no glyph also varies over terminal emulators.GB9, GB9a, GB9b, GB9c
Nonspacing MarkandEnclosing Mark: Zero-widthCharacter after
ZWJ: Zero-widthOther: Follow east asian width
Do nothing for
Prependbecause width varies over terminal emulators.GB11
Assume combined emoji exists, Assume
Extendto beNonspacing Mark.Character after
ZWJ: Zero-widthGB12, GB13
Flag emoji width varies over terminal emulators and its configurations. Unable to handle it now.
Width calculation change from 1 to 2 in this pull request.