We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm writing a teleprompter program which scrolls a large block of text vertically on and off the screen. I need to load in an arbitrary amount of text, word wrap it so it vertically runs off the bottom of the display area but fits within the width of my display area, and then scroll it up the screen. What I've been doing so far is loading all the text into a String and drawing that with text(x,y,displayWidth, displayHeight). That forces the text to word wrap, but any portion of the String outside of those defined dimensions is simply truncated. So it seems that I need to define a taller rectangle than what appears on screen in order to make sure all of the String data is preserved. But how can I figure out how tall to make it without first using text() to force it to word wrap? Obviously this must be the wrong approach.
I also had the thought to do my own manual word wrapping, splitting the String up into an ArrayList, and then writing my own routine to draw each individual line of text with its appropriate vertical offset. I even found this bit of code to do the word wrapping: http://wiki.processing.org/w/Word_wrap_text
One problem: it doesn't seem to work. It throws a NullPointerException about the time it gets to "w += textWidth(c)". I've tried stepping through it line by line and rewriting it myself, but I just can't seem to figure out what the problem is.
So, am I missing something obvious with either approach #1, or with the error I'm having in the manual word wrap?
Thanks!
Answers
Without seeing your code I can't know, but perhaps this is relevant: http://forum.processing.org/two/discussion/1118/is-textwidth-misbehaving-itself-or-am-i-missing-something