FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 464 : 0122 textFont() seems to not be working properly
Last modified: 2007-02-03 09:38
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
ScottLawrence
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2006-11-30 17:42
on Processing 0122 (not on 0121), textFont() seems to need to be called from within draw()
rather than in setup().
The following snippet of code works great under 0121, but fails on 0122
[quote]
[color=#777755]// 0122 test for text/textFont();[/color]
[color=#CC6600]PFont[/color] myFont;
[color=#996600]int[/color] i;
[color=#CC6600]void[/color] [color=#993300][b]setup[/b][/color]()
{
[color=#996600]size[/color]( 200, 200 );
myFont = [color=#996600]loadFont[/color]( [color=#CC0000]"Garamond-24.vlw"[/color]
);
[color=#996600]textFont[/color]( myFont, 24);
[color=#996600]textAlign[/color]( [color=#CC0000]CENTER[/color] );
}
[color=#CC6600]void[/color] [color=#993300][b]draw[/b][/color]()
{
[color=#996600]background[/color]( 0 );
[color=#996600]fill[/color]( 255 );
[color=#CC6600]String[/color] txt = [color=#CC0000]""[/color] + (++i);
[color=#996600]text[/color]( txt, [color=#CC0000]width[/color]/2, [color=#CC0000]
height[/color]/2 );
}
[/quote]
It yields this error:
[quote]
java.lang.RuntimeException: use textFont() before text()
at processing.core.PGraphics.text(PGraphics.java:2373)
at processing.core.PApplet.text(PApplet.java:7246)
at Temporary_3082_150.draw(Temporary_3082_150.java:20)
at processing.core.PApplet.handleDisplay(PApplet.java:1314)
at processing.core.PGraphics.requestDisplay(PGraphics.java:564)
at processing.core.PApplet.run(PApplet.java:1409)
at java.lang.Thread.run(Thread.java:552)
[/quote]
It seems to fail with any font. If you move the textFont() into draw() it works fine.
Additional Comment
#1 From ScottLawrence 2006-11-30 17:43
// 0122 test for text/textFont();
PFont myFont;
int i;
void setup()
{
size( 200, 200 );
myFont = loadFont( "Garamond-24.vlw" );
textFont( myFont, 24);
textAlign( CENTER );
}
void draw()
{
textFont( myFont, 24);
background( 0 );
fill( 255 );
String txt = "" + (++i);
text( txt, width/2, height/2 );
}
Additional Comment
#2 From fry 2006-11-30 17:47
0123 should fix this, give that a try and let me know how it goes.
Additional Comment
#3 From ScottLawrence 2006-11-30 18:42
Yes. Indeed it does. 0123 does fix it. :D