Wrapping Text on Canvas

BlitzPlus Forums/BlitzPlus Beginners Area/Wrapping Text on Canvas

jogger(Posted 2007) [#1]
I would like to have a paragraph of text appear on a canvas, however, the text does not wrap. If I use a label, the text wraps, but I can't change the text size or color. Does anyone have a solution?


Alaric(Posted 2007) [#2]
Here's a function that should get help you out.

Function disptext(x,y,disptext$,canvas)
SetBuffer(CanvasBuffer(canvas))
Repeat
If lastfound >= previousfound
tmpstr2$=tmpstr$
tmpstr$=Mid$(disptext$,lastcut,Instr(disptext," ",lastfound)-lastcut)
If StringWidth(tmpstr$) > ClientWidth(canvas)
Text x,y,Trim$(tmpstr2$)
lastcut=previousfound
y=y+StringHeight(disptext)
End If
previousfound=lastfound
lastfound=Instr(disptext," ",lastfound+1)
Else
Exit
End If
Forever
Text x,y,Right$(disptext$,Len(disptext)-lastcut)
End Function