Originally Posted by knc1
Sounds like justification is applied prior to hyphenation (it would almost have to be, to determine if the line is too long).
It might be fixable, but would probably not be pretty to code.
I leave the details to the author's reply.
It is (from a coding standpoint) similar to the not justifing and hypenating of the last line of the page.
What do you do with any over-flow if that is the last page of the document?
Also related, not only do you typically not justify the last line of text, but something similar is done when the text wraps to a new page.
I worked on a word processor in the olden (minicomputer) days of computing. We called last lines wrapped to a new otherwise empty page "widow lines". We had a rule that the last TWO lines of text must get wrapped to the last page to prevent widow lines. That created a much more pleasing-to-view document. Perhaps something similar could be applied here.
Text justification actually has a lot more rules than these two mentioned here. We had a rather large book of rules, many of which controlled text justification. It is not as simple as you would think. One example that comes to mind is that you do not wrap a proper name to a new page, because it is capitalized and looks like the beginning of a new sentence when at the start of a new page. Beginning a page with a lower-case letter is one of the clues that tell us to seek the beginning of the sentence on the previous page when thumbing (leafing/browsing) through a book. There are more rules like this, and some rules have exceptions, and the exceptions have exceptions (such as when wrapping indented text).
Sometimes, it is fun to move the hyphenation for humorous effect, such as changing co-worker to cow-orker. http://catb.org/jargon/html/C/cow-orker.html