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.
Page Index Toggle Pages: 1
textFont (Read 2349 times)
textFont
Apr 19th, 2005, 4:32pm
 
Not sure if this is a bug, or a feature.

If you put textFont(...) before size(...) the textFont information is lost, and the applet will crash when you try to run it with the error:

java.lang.RuntimeException: use textFont() before text()      at processing.core.PGraphics.text(PGraphics.java:1671)      at processing.core.PGraphics.text(PGraphics.java:1643)      at processing.core.PApplet.text(PApplet.java:5893)      at Temporary_6986_8011.draw(Temporary_6986_8011.java:12)      at processing.core.PApplet.display(PApplet.java:1070)      at processing.core.PGraphics.requestDisplay(PGraphics.java:362)      at processing.core.PApplet.run(PApplet.java:916)      at java.lang.Thread.run(Unknown Source)

example code:
Code:

PFont f;
void setup()
{
f=loadFont("Arial-48.vlw");
textFont(f,32);
size(300,200);
noLoop();
}

void draw()
{
text("Hello, world!",5,100);
}
Re: textFont
Reply #1 - Apr 19th, 2005, 4:38pm
 
yup, if you have a call to size(), make sure it's the very first thing in your setup:
http://processing.org/reference/size_.html
Re: textFont
Reply #2 - Apr 19th, 2005, 4:43pm
 
Fair enough, it's jsut a change from Alpha that caught me out with one of the applets I've worked on a fair bit, was simple enough to sort out.
Re: textFont
Reply #3 - Apr 19th, 2005, 7:33pm
 
i'll add to the changes section of the faq as well.
Page Index Toggle Pages: 1