This code will justify it too!
If you can shorten it, please do.
Graphics 800,600,32,2 Type word Field content$ End Type SetBuffer BackBuffer() squaretext("This is a really long string to test my function. I hope it works. But it may not. It ought to be long enough soon. Like now. That's probably good. Ok. Stopping the rambling. Yup. Ok. I'm really done now.",0,0,100) Flip WaitKey End Function squaretext(incoming$,x,y,width) While incoming$<>"" If StringWidth(incoming$)>width temp$="" tempnum=1 While StringWidth(temp$)<width temp$=temp$+Mid$(incoming$,tempnum,1) tempnum=tempnum+1 Wend While Not Right$(temp$,1)=" " temp$=Left$(temp$,Len(temp$)-1) Wend incoming$=Right$(incoming$,Len(incoming$)-Len(temp$)) If Left$(incoming$,1)=" " incoming$=Right$(incoming$,Len(incoming$)-1) End If While Right$(temp$,1)=" " temp$=Left$(temp$,Len(temp$)-1) Wend justifiedtext(temp$,x,y,width) Else Text(x,y,incoming$) incoming$="" End If y=y+FontHeight() Wend End Function Function justifiedtext(curline$,x,y,width) tempx#=x spacing#=Float#(width)/Float#(Len(curline$)) For a=1 To Len(curline$) Text(tempx,y,Mid$(curline$,a,1)) tempx#=tempx#+spacing# Next End Function
If you can shorten it, please do.