I need to draw a string on a canvas.
I made a clip called imagenclinica .
The string is called clinica and it comes from an user’s input so I don´t know its width.
This string (clinica) should be centered in the clip (imagenclinica).
I made this possible this way:
There is no problem as long as clinica’s width is less or equal to imagenclinica’s width.
If the string width is greater than the clip width, then I will need to wrap, resulting in a second line of text. I will also need to adjust text size so both lines of text fit into the clip height. I can make string size half the original one so that is not the problem.
How can I wrap and keep both lines of text centered?

You’ll have to to the line break yourself. Split the text using spaces and then use a while loop to keep adding each word until you go over the width, then back off by one.

I did this for a Teleprompter program a few years ago.

Got it. But what about centering each line?

you draw it centered using drawstring and calculating the right x offset so its centered

x = width/2 - stringwidth/2