I have:
This is a test string. Cool, huh?
I want:
This is a te-
st string. C-
ool, huh?
That is, each line is
The libraries Hyphenator or Org_Heigl/Hyphenator seem to be handling hyphenation properly. Based on one of those, you should be able to write your own wordwrap()
able to use either spaces or hyphens as break points.
Note that English words have very specific hyphenation points, and you're absolutely not guaranteed to have each line exactly n characters long. Sometimes you'll fall a few characters short, if the next syllable just happens to be long - for example "thorough" hyphenates as thor-ough, while "through" does not hyphenate at all.