Skip to main content

text_width

Function text_width 

Source
pub fn text_width(text: &str) -> u16
Expand description

The width in cells of text: the sum of cluster_width over its extended grapheme clusters. A sum over u16::MAX saturates.

The sum is per cluster, so it can exceed the width a terminal gives a run that shapes into one glyph across clusters. The Arabic lam followed by alef is two clusters of 1 cell each, so 2, though a font may draw one ligature.