I made "clever" function that fills the text with spaces to fit a certain size.
I had to find the text size and did that using temporary text and the GetTextTotalWidth() command.
So this might help if you need to find the place where to wrap around:
function Core_FillTextEndWithSpaces(String$,MaxWidth#,Size#,Spacing#)
StringTextID=CreateText(String$)
SetTextSize(StringTextID,Size#)
SetTextSpacing(StringTextID,Spacing#)
StringWidth#=GetTextTotalWidth(StringTextID)
SpaceTextID=CreateText(" ")
SetTextSize(SpaceTextID,Size#)
SetTextSpacing(SpaceTextID,Spacing#)
SpaceWidth#=GetTextTotalWidth(SpaceTextID)
RemainingWidth#=MaxWidth#-StringWidth#
SpaceCount=round(RemainingWidth#/SpaceWidth#)
String$=String$+Spaces(SpaceCount)
DeleteText(StringTextID)
DeleteText(SpaceTextID)
endfunction String$