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 › Intermittent textFont() / textSize() issue
Page Index Toggle Pages: 1
Intermittent textFont() / textSize() issue (Read 321 times)
Intermittent textFont() / textSize() issue
Feb 26th, 2008, 2:21am
 
Forgive me if this is a lame question... I did search the forum but didn't see it mentioned in the archive.

I'm going through Ben Fry's "Visualizing Data" book (and really enjoying it by the way) and building up the sample code as I progress.

In many cases, the font for a program is loaded in setup() through the use of createFont() and textFont(). Later, once the draw() loop has started, textSize() is called to modify the size of labels at various times.

Most of the time, I get an exception telling me "Use textFont() before textSize()"... and I can certainly modify the code to call textFont() repeatedly, except that:

1) It doesn't occur EVERY time I run my program. Sometimes, I can hit CTRL+R repeatedly and it will run after 4-5 tries without modification. Weird.

2) The sample code doesn't call textFont() before each textSize call().

Am I missing something here? It seems that calling it once in setup() should take care of it (and that seems to be what the sample code from the book implies as well).

FWIW, I'm running Processing 0135 Beta under Windows Vista.

Thanks in advance,

Jeff
Re: Intermittent textFont() / textSize() issue
Reply #1 - Feb 26th, 2008, 8:11am
 
Yeah, somebody else ran across the same problem:
http://dev.processing.org/bugs/show_bug.cgi?id=726

The fix for now is to call textFont() inside draw() before using the text() command. I've seen quirks like this before but I'm not sure where this one is coming from (Vista? Sunspots?) Will look into it more for the next release.
Re: Intermittent textFont() / textSize() issue
Reply #2 - Feb 26th, 2008, 6:57pm
 
fry wrote on Feb 26th, 2008, 8:11am:
The fix for now is to call textFont() inside draw() before using the text() command. I've seen quirks like this before but I'm not sure where this one is coming from (Vista Sunspots) Will look into it more for the next release.


Thanks, Ben... that's easy enough.

BTW, I'm finding the book to be a great walkthrough/introduction to working with processing... I've done Java for years (and .NET more recently) and the simplicity of getting started with processing is REALLY refreshing.
Re: Intermittent textFont() / textSize() issue
Reply #3 - Feb 26th, 2008, 8:23pm
 
great! good to hear.
Page Index Toggle Pages: 1