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 › Text displaying pixelated
Page Index Toggle Pages: 1
Text displaying pixelated (Read 1204 times)
Text displaying pixelated
Sep 24th, 2009, 2:51pm
 
Good afternoon!
I am encountering an issue with the display of Fonts. When I put a drawLabels() method anywhere except in setup(), the display appears jagged. The font size is not different  

Has anyone encountered this before? Any ideas?

Here is a stripped down version of the code:

PFont font35, font25;
int diameter;

void setup(){
 size(500, 500);
 smooth();
 background(255);
 diameter = 380;
 fill(#eeeeee);
 noStroke();
 ellipse(width/2, height/2, diameter+5, diameter+5);
}

void draw(){
   fill(174,221,20);
   drawLabels();
}

void drawLabels(){
 fill(130);
 font25 = loadFont("ArialNarrow-25.vlw");
 textFont(font25, 25);
 
 font35 = loadFont("ArialNarrow-35.vlw");
 textFont(font35, 35);
 text("This is the text", 15, 40);
}
Re: Text displaying pixelated
Reply #1 - Sep 24th, 2009, 4:58pm
 
 background(255); thats it....
Re: Text displaying pixelated
Reply #2 - Sep 24th, 2009, 8:07pm
 
Code:
PFont font35, font25;
int diameter = 380;

void setup(){
 size(500, 500);
 smooth();
 font35 = loadFont("ArialNarrow-45.vlw");
// or
// recommended if not exporting to web applet
// font35 = createFont("Arial Narrow", 45);
}

void draw(){
 background(255);
 noStroke();
 fill(#eeeeee);
 ellipse(width/2, height/2, diameter+5, diameter+5);
 drawLabels();
}

void drawLabels(){
 fill(130);
 textFont(font35, 35);
 text("This is the text", 15, 40);
}


Do not initialize PFonts in the draw() or other functions if they repeat in loops or inside the draw() funtion, loading the font from the data folder takes some time, initialize the PFonts in setup() instead. When creating a font with the tools menu, if you can, make the font bigger than it will be displayed make a 35px font for a 25px displayed text, they tend to look better. Update the background on the begining of each draw() cycle. If your aim is trying to keep the circle in the background, then put it as the first thing after the background() update.

The end.
Re: Text displaying pixelated
Reply #3 - Sep 25th, 2009, 1:21am
 
yep, 0p0 said everything additional i should have said.
Was late last night, sorry Smiley
Re: Text displaying pixelated
Reply #4 - Sep 25th, 2009, 9:18am
 
Fantastic!
Thank you for the thorough explanation!
I should have thought better than to move all my font code around in chunks:

font35 = loadFont("ArialNarrow-35.vlw");
textFont(font35, 35);
text("This is the text", 15, 40);

Thanks!

Problem solved!
Re: Text displaying pixelated
Reply #5 - Sep 25th, 2009, 9:36am
 
like he said, the first line in setup the second one, in setup or draw if you wanna change it, and the last one in draw...
Re: Text displaying pixelated
Reply #6 - Sep 27th, 2009, 1:21pm
 
It's great to be helpful Cheesy
Page Index Toggle Pages: 1