We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I just work on sketch to display simple Text on a single screen. The Text is loaded from a String and displayed word by word. Now comes my problem: It would be great if each Word would scale to the screen size. Means either the word length or height fits the screen width / height.
Does anybody know how to do that?
You could use
textSizeand increase it until
textWidthgives you the right size then display it - see example below [EDITED]
The final product is a animation of about 25 minutes. So I hoped the program to do that for me.
Check this post: https://forum.processing.org/two/discussion/comment/83538/#Comment_83538
In the reference, Have a look at this:
That's exactly what I meant.
Let the sketch run a simulation for you, finding the textSize (matching the windows width)
Wow, I just did not get it. Sorry! I thought you ask me to try it manually for each word :) but your solution is so easy.
Thank you a lot!
textWidth takes into account the current textSize, that's why it works
You can use this fittedText function to do that without iterating through so many possible text sizes:
It will fit to the input fitX and fitY size, but you can just send in "width" and "height" to make it fit to screen, if you need to fit it to other sizes though you can do that as well.
I adjusted Chrisir s answer like that
that's the full sketch from baltensperger with my approach by the way (but I think San's approach above is much better)