calculateBalancedLines

fun calculateBalancedLines(syllableLayouts: List<SyllableLayout>, availableWidthPx: Float, nativeEngine: NativeTextEngine, style: ERROR CLASS: Symbol not found for TextStyle, density: ERROR CLASS: Symbol not found for Density): List<WrappedLine>

Calculates line wrapping for syllables using a balanced (minimum raggedness) algorithm (Knuth-Plass inspired dynamic programming approach).

Tries to distribute words evenly across lines to minimize empty space at the end of lines. Falls back to greedy wrapping if optimization fails to find a valid solution.

Return

List of WrappedLine representing the broken lines.

Parameters

syllableLayouts

List of pre-measured syllable layouts.

availableWidthPx

Maximum width available for a line.

nativeEngine

Native engine (used for trimming/re-measuring if needed).

style

Text style.

density

Screen density.