Dynamic Text Resizing

Is there a way I can stop a single word splitting over two lines when putting dynamic text into a fixed width, multiline text field?

I have a simple method of checking if there are more lines than words and then running a while loop to reduce the font size until there are the same amount or less lines than words. But this doesnt always work, if say the final word of three is quite short and the second word splits over two lines then I still have 3 words and 3 lines.

If anyone has a good example or advice it would be extremely appreciated.