func (canvas *Canvas) WrapLines(dst []string, value string, size, weight, width float32, maxLines int) []string
WrapLines breaks value into lines no wider than width at font size size and
weight (TextStyle.Weight) and appends them to dst, at most maxLines of them.
Where a line may break follows UAX #14 (internal/linebreak): after spaces, hyphens and
most punctuation as the standard's pair rules say, between ideographs, kana and
emoji with the line-start and line-end rules of East Asian typesetting, between the
syllables of the dictionary-less scripts (Thai, Lao, Khmer, Myanmar) at the places their
writing allows, and at a newline in the text (a trailing CR is dropped). Two
tailorings: Hangul syllables break at spaces as Korean text is set (a Korean word is
kept whole when it fits a line), and a word wider than a whole line (a URL, a path, a
hash) breaks after the last / \ - _ . & ? = that fits and failing that after the last
grapheme cluster (UAX #29) that fits, so a base with its marks, an emoji sequence, a
flag, a conjunct is never split.
A line always holds at least one character, however narrow the width. When the
text needs more than maxLines, the last line ends with an ellipsis. The
lines are slices of value, so wrapping text that fits builds no strings; only
the ellipsized last line is new (see WrapLinesCached). Draw the result one
Label per line.
lines := canvas.WrapLines(scratch[:0], message, 12, ui.WeightRegular, bounds.Width, 3)
for index, line := range lines {
canvas.Label(line, ui.Rect{X: bounds.X, Y: bounds.Y + float32(index)*17, Width: bounds.Width, Height: 17}, style)
}
Widths are measured at weight, the one the lines are drawn with: a heavier
line is wider.