Fun problem. Here's a c# version. I needed this for a mobile game that runs in a variety of resolutions. Couldn't find anything so I rolled my own. I was surprised by the complexity of this problem so posting this hoping it will save you some time if you need to drop some c# code into an existing project.
Example (using 10 character search radius):
int maxLineLength = 75;
var input = @"This extra-long paragraph was writtin to demonstrate how the `fmt(1)` program handles longer inputs. When testing inputs, you don't want them be too short, nor too long, because the quality of the program can only be determined upon inspection of complex content. The quick brown fox jumps over the lazy dog. Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.";
int maxLineCount = (int)(3.0 * input.Length / maxLineLength);
var result = UniformLineSplitting.Split(
input, maxLineLength, 1, maxLineCount, UniformLineSplitting.Western);
Assert.AreEqual(
@"This extra-long paragraph was writtin to demonstrate how the `fmt(1)`
program handles longer inputs. When testing inputs, you don't want them
be too short, nor too long, because the quality of the program can only be
determined upon inspection of complex content. The quick brown fox jumps
over the lazy dog. Congress shall make no law respecting an establishment
of religion, or prohibiting the free exercise thereof; or abridging the
freedom of speech, or of the press; or the right of the people peaceably
to assemble, and to petition the Government for a redress of grievances.",
result);