What's an efficient algorithm to calculate line breaks (word wrap) for balanced widths (minimum raggedness)?
Have you considered using the total-fit line breaking algorithm(a) used by TeX(b) and developed by Donald Knuth and Michael Plass?


Donald Knuth and Michael Plass. "Breaking Paragraphs into Lines".


https://github.com/jaroslov/knuth-plass-thoughts/blob/master/plass.md
https://github.com/baskerville/paragraph-breaker
https://cs.uwaterloo.ca/~dberry/ATEP/StudentLectures/Ananya.pdf
https://news.ycombinator.com/item?id=1134342
https://www.tug.org/TUGboat/tb21-3/tb68fine.pdf

Remco Bouckaert. "A Probabilistic Line Breaking Algorithm".


Edit:

The total-fit line breaking algorithm has already been implemented in many languages, including Java:


"Knuth &amp; Plass line-breaking Revisited" in Java
"The linebreaking algorithm of Knuth and Plass" in Java (via Generalized Knuth-Plass Linebreaking Algorithm)
"rosettacode: Word wrap" has implementations of the Knuth Plass algorithm in a variety of languages