Bug 1207 : improve speed of text(x, y, w, h) when using large strings with no spaces
Last modified: 2009-03-17 15:31




Status:
ASSIGNED
Resolution:
-
Priority:
P5
Severity:
enhancement

 

Reporter:
mkn
Assigned To:
fry

Attachment Type Created Size Actions
Simple code to illustrate text() rendering lag application/force-download 2009-03-16 03:40 44.35 KB

Description:   Opened: 2009-03-15 07:55
1. Using long strings of characters without any breaking ones stops execution.

2. There is no way to turn off wrapping of entire words? Nothing in the
Processing JavaDoc either (AFAICouldFindWithGoogle). A lil boolean would
do. :)
Additional Comment #1 From fry 2009-03-15 10:25
please post a short sketch (then use archive sketch, and attach it to the
bug report), i don't quite follow.
Additional Comment #2 From mkn 2009-03-16 03:40
edit]
Simple code to illustrate text() rendering lag
Additional Comment #3 From mkn 2009-03-16 03:41
1. Aha. Spotted it. It seems that the cocktail of large fonts and a very
long string without spaces is a bad one. When the above fed to text(), P5
renders the entire string even though only a fragment is visible, thus
taking so long time that execution seems to be halted as no indication is
given of what is going on.

This means that text() currently relies on spaces (and \n) for preliminary
segmentation before rendering. (Arguably this might be up to the user to
know his/her code, so maybe just a warning in the console would be enough.)

2. The way text() works now is that it wraps words automatically to the
next row, which is a good default setting. It would be useful with a flag
to simply wrap per character instead, like text.wordWrap(false) (Maybe
there is, but I couldn't find it in the JavaDoc), or optional by
punctuation (as mentioned above), like text.wordWrap( WRAP_WORDS |
WRAP_CHARS | WRAP_PUNCTUATIONS | ... ) for future proof extendability.


PS. Um, yeah. Sorry about that initial bug report. It was not very useful.
Tired etc. :)
Additional Comment #4 From fry 2009-03-17 15:31
as far as i can tell, this isn't a bug--it's just slow when you have
exceptionally long lines with no spaces, so i'll mark this as an
enhancement request. (it's also gonna depend on your machine, java version,
renderer setting, etc...)

if a word doesn't fit on the line, it breaks and wraps to the next row the
same way as text blocks work in other programs (such as page layout software).
This bug is now being tracked here.