layoutRichText
fun layoutRichText(spans: List<Span>, maxWidth: Float, align: TextAlign, paragraphLineHeight: Sp, metrics: FontMetrics): MeasuredRichText
Word-wraps the supplied spans across maxWidth.
The algorithm flattens every span into a stream of (word, style) tokens (preserving spaces as zero-width separators), then runs the same first-fit greedy wrapper as plain text — but with per-token style awareness. When a line break happens inside a span, the span is physically split so each line records the slice of text it contains.
Hard newlines (\n) inside a span text always force a break.
Spans whose style sets TextScript.Superscript / TextScript.Subscript are measured at a reduced size and receive a per-segment baseline shift; TextAlign.Justify stretches the inter-word spaces of every line except the last line of each hard paragraph.