Build one highlight rectangle per visual line in a text range.
Text extraction commonly splits a line into several fragments (words,
spaces, font runs, or direction runs). Painting those fragments separately
leaves seams and gaps in what is visually one selected line. This function
joins consecutive fragments whose cross-axis extents overlap, while explicit
line breaks and horizontal/vertical orientation changes always start a new
rectangle.
Build one highlight rectangle per visual line in a text range.
Text extraction commonly splits a line into several fragments (words, spaces, font runs, or direction runs). Painting those fragments separately leaves seams and gaps in what is visually one selected line. This function joins consecutive fragments whose cross-axis extents overlap, while explicit line breaks and horizontal/vertical orientation changes always start a new rectangle.