TermBuf::Unicode::WidthPolicy
Stability: stable — changes only in a major release.
How a particular terminal measures a grapheme cluster.
UAX #29 says where a cluster ends and UAX #11 says how wide a character is. Neither says what a terminal does with four emoji joined by zero width joiners, and terminals disagree: some advance two columns, some eleven. A buffer measuring a cluster differently from the terminal drawing it has every later cell on that row in the wrong place, so the measurement has to come from the terminal rather than from the standard.
WidthProbe fills one of these in by asking. The defaults are what a
current terminal does, and what a terminal that answers nothing is assumed
to do.
Constants
What a current terminal does.
Every rule by name, for diagnostics and for TERMBUF_WIDTHS to check
against.
Constructors
Instance methods
Cells an East Asian Ambiguous character takes. One on most terminals, two on a terminal configured for CJK text, and the standard leaves it to the environment.
Whether a spacing mark beside a conjunct adds a column on top of the two the conjunct already takes, rather than fitting inside them.
क्षि is a conjunct with a vowel sign, and iTerm2 3.6.11 advances three
columns for it where ghostty and Terminal.app advance two. Every other
rule here tops out at a cell pair; this is the one reading that needs a
third cell, and Cell::MAX_WIDTH is as far as any of them may go.
Whether a consonant conjunct joined by a virama is two columns whatever it opens with, rather than as wide as the consonant it starts from.
A conjunct ligates into one glyph, and what a terminal charges for that
glyph is its own decision: ghostty and Terminal.app take two, kitty
0.48.2 takes one — क्ष is a single column there, and so is क्षि.
The companion of joined_emoji_wide, and the same kind of question.
Whether U+FE0F widens a pictograph that would otherwise be text. Without
it ☺️ is as narrow as ☺.
Whether the rule name is on. ambiguous_wide reads as a flag here even
though it is stored as a count.
Whether an emoji sequence joined by U+200D collapses to the width of one emoji. Without it the cluster is as wide as its pieces laid end to end.
Whether a collapsed joined sequence is two columns whatever it opens with, rather than as wide as the code point it starts from.
Ghostty, kitty and tmux draw two for a weight lifter joined to a female
sign, which opens with a narrow pictograph. iTerm2 3.6.11 draws one, and it is alone in that among
the terminals surveyed — see measurements/survey/. It is not a Quirk:
nothing is broken by it, and a buffer told about it lays the row out
correctly.