Answer the question
In order to leave comments, you need to log in
How to align text when overlaying an image?
Let's say I have a string: aaa bbb cccccc
approximately 200px wide. And I want to overlay this line on the image. But there is a moment! The text width needs to be 100px. Those. so that the text is overlaid like this:
aaa bbb
cccccc
Those. so that what does not fit into the given width is wrapped on a new line. Answer the question
In order to leave comments, you need to log in
I will describe the algorithm.
length = 0
str = "aaa bbb cccccc"
resstr = ""
curstr = ""
for i=0; i<strlen(str); i++
curstr .= str[i];
if вычислить_ширину(curstr) > 100
resstr .= curstr . "\n"
curstr = ""
end if
end for
resstr .= curstr
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question