We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Wrapped text - length
Page Index Toggle Pages: 1
Wrapped text - length? (Read 635 times)
Wrapped text - length?
May 29th, 2009, 10:13pm
 
Hello,

I'm using text(stringdata, x, y, width, height) and have been trying to work out how to tell if the text is longer than the width & height available. Whether all the text is visible or not.

I tried calculating using textAscent, textDescent, a count of new lines and the size of the box but that doesn't work because the wrap happens at words.  I also couldn't see how to find the default leading - textLeading() is for setting the leading, not getting it.

Is there an easier way than calculating the text line by line?

thanks,

Brenda
Re: Wrapped text - length?
Reply #1 - May 30th, 2009, 8:33am
 
Great question.  There's no easy way to do this built into Processing.  If you develop a custom method for doing this and decided to share it, lots of other people (like me) would benefit.

Processing gives you textWidth(), but that isn't useful for blocks of text (i.e. more than one line).  As far as I know, there's not an easier way (yet).  Good luck!
Re: Wrapped text - length?
Reply #2 - May 30th, 2009, 8:34am
 
Oh, and I think the default leading is just whatever point size you've specified, as in textFont(fontName, 24), so the leading would be 24 unless specified otherwise.
Page Index Toggle Pages: 1