Wrapping Algorithm is Inaccurate

The wrapping algorithm is inaccurate (version 8.6), try this example:

This is the result:

The result in left text widget seems to be odd, it should wrap after "wraps" like on the right side (here a linebreak is used), and not before. The original wrapping algorithm wraps if at least one pixel at right border remains. This doesn't make sense, because the user cannot use this remaining pixel, he cannot position the cursor after this pixel, and this remaining pixel also has no visible effect, so the line wrapping should be done after the word "wraps". Moreover it is expected that up to 20 characters will fit into one line, because the width of this widget is set to 20. The revised implementation is producing the result on the right side.