text$ = "This is a bunch of foobar! "
text$ = text$ + text$
Calculate_WordWrap text$, 300, foo()
LINE (301, 0)-(640, 480), &HFFFF0000, BF
'and now to try with a different font
PRINT "NOTE: This test is with a non-monospaced font, so if your PC is like mine, expect your fans to kick in, CPU usage to skyrocket, and for this process to take a few seconds."
Calculate_WordWrap text$, 300, foo()
LINE (301, 0)-(640, 480), &HFFFF0000, BF
'and now to try with a different font
PRINT "NOTE: This test is with the same font" PRINT " set as MONOSPACE, just to test" PRINT " the speed difference."
Calculate_WordWrap text$, 300, foo()
LINE (301, 0)-(640, 480), &HFFFF0000, BF
SUB Calculate_WordWrap
(temp$
, wide%
, result
() AS STRING) BreakPoint = ",./- ;:!" 'I consider all these to be valid breakpoints. If you want something else, change them.
'first find the natural length of the line
lineend = i - 1
t$
= RTRIM$(LEFT$(text$
, lineend
)) 'at most, our line can't be any longer than what fits the screen. count = count + 1
clean_exit: