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
Fonts (Read 964 times)
Fonts
Jan 24th, 2007, 9:31pm
 
Hi There,

I am new here and I do programming for the first time. Its kind of difficult because I am Polish and not a native, so I have difficulties with understanding everything correctly sometimes.

But I was already successful in doing some examples of the "Learning Page".Smiley

Now I would like to load the font but I don't understand how to proceed. Fonts should be located within the main Processing directory folder.----I cannot find them there. Where do I have to look exactly? "Fonts must be placed within the data directory ot the sketch." How do I do this?

Looking forward for some help.
With thanks,

clicker
Re: Fonts
Reply #1 - Jan 24th, 2007, 10:05pm
 
inside Processing, click "Tools" in the top-menu. select "Create Font .." and then another window pops open. select the font you want to use, choose a size, copy the name and click OK. now back in the main window you can do:

PFont myFont = loadFont( "Name Of The Font.vlw" ); // paste the name in .. add ".vlw"

the font has been created for you and was placed inside your sketch folder by Processing. the loadFont-name should match the filename ....

here's how to use fonts:
http://processing.org/reference/PFont.html

good luck,
F
Re: Fonts
Reply #2 - Jan 25th, 2007, 3:24am
 
Hi,

thank you so much, your description was helpful!
I have "created" this here:

PFont font;
font = loadFont ("AharoniBold-48.vlw");
textFont (font, 20);
int x = 30;
fill(0);
text ("here", x, 20);
fill (52);
text ("we", x, 45);
fill (52);
text ("go", 50, 80);

How can I make these words somehow movable or made them loop. I wonder in which order commands have to be stated.
Maybe I can ask you for an example made out of my "my creation"?

It will be greatly appreciated! Thank you!!
Re: Fonts
Reply #3 - Jan 25th, 2007, 11:09am
 
If you want to make them move, then you'll have to step up to the slighly more complicated Processing syntax:

Code:
PFont font;
int x;
void setup()
{
size(200,200);
font = loadFont ("AharoniBold-48.vlw");
textFont (font, 20);
x=30;
}

void draw()
{
background(255); // white screen, clears last frame, or everything will smear.
fill(0);
text ("here", x, 20);
fill (52);
text ("we", x, 45);
fill (52);
text ("go", 50, 80);
x=x+1;
}
Re: Fonts
Reply #4 - Jan 26th, 2007, 3:25am
 
Thank you!!

And how do I make the words come down?
I guessed I should change x to y but nothing changed:

PFont font;
int y;
void setup()
{
 size(200,200);
 font = loadFont ("AngsanaNew-48.vlw");
 textFont (font, 30);  
 y=10;
}

void draw()
{
 background(255);
 fill(0);
 text ("here", y, 20);
 fill (52);
 text ("we", y, 45);
 fill (52);
 text ("go", y, 80);  
 y=y+1;  
}

Re: Fonts
Reply #5 - Jan 26th, 2007, 9:31am
 
changing what you call the variable doesn't change anything, what matters is where in the function call you put it:

Code:

text("here",y,20);
. ^ ^ ^- Y-position
. The |
. text X-position


So you see even though you've called it y, it's in the X-position space, so that's what it does, change the X position. To make it change the Y position you want:

Code:
fill(0);
text("here",20,y);
fill(52);
text("we",20,y+25); // +25 or it'll be directly on top of "here"
// etc, etc.
Re: Fonts
Reply #6 - Jan 26th, 2007, 9:40am
 
in your sketch x and y are just the name of variables so u can call them as u want (even foobar) it won't change the way ur program work.

If you look at the reference for text() it says text(data, x, y) with x for x-coordinate of text and y for y-coordinate of text.

So if you want it to scroll down u need to modify the third parameters of text() like that :

PFont font;
int y; //or u can initialize it there int y=0;
void setup()
{
 size(200,200);
 font = loadFont ("AngsanaNew-48.vlw");
 textFont (font, 30);  
 y=0;
}
 
void draw()
{
 background(255);  
 fill(0);
 text ("here", 20, y);
 fill (52);
 text ("we", 45, y);
 fill (52);
 text ("go", 80, y);  
 y=y+1;  
}

And if u want the text to loop between the top of the screen and the bottom u can try that :

PFont font;
int y; //or u can initialize it there int y=0;
void setup()
{
 size(200,200);
 font = loadFont ("AngsanaNew-48.vlw");
 textFont (font, 30);  
 y=30;
}
 
void draw()
{
 background(255);  
 fill(#F7B711);
 text ("here", 20, y);
 fill (52);
 text ("we", 90, y);
 fill (52);
 text ("go", 140, y);
 if (y > height-30){
   y=30;
 }
 else{  
   y=y+1;
 }  
}

Hope it helps.
Re: Fonts
Reply #7 - Jan 26th, 2007, 9:42am
 
oups sorry am at work and didn't saw u already give an anwser !!!
Page Index Toggle Pages: 1