Hi,
I’m trying to figure out a way to make a ttf string surface with SDL_ttf.
The problem is I needed to cut the string surface if the string is too
long, it will be cut and a new string surface under it will be created. In
other word, I need to implement a word wrap function to it. What I have in
mind is this:
- Render the string
- Check the surface’s dimension (h & w)
- If it’s to long:
3.1. Free the surface
3.2. Cut the last word from the string and push to a new string
3.3. Re-render the string
3.4. Loop to 2 - If not:
4.1. Check if there’s a new string generated from the last string
4.1.1. If there is a new string:
4.1.1.1. Loop to 1
4.1.2. If not:
4.1.2.1. End
IMHO, the render, re-render, free loop will take a long time to process.
Is there any other way to solve this elegantly?
Thanks in advance.
Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!
?Do nothing which is of no use.? - Miyamoto Musashi.
“I live for my dream. And my dream is to live my life to the fullest.”