ucall more than one Pfont in a processing progam
Closed this issue · 3 comments
Driving me crazy! Need to change fonts in a short processing program. It is an assignment to complete for homework. The basic program works, but am a loss on where to/ how to chnage the font and insert the text in that new font. Thanks!
My basics:
PFont myFont;
void setup()
{
size(200, 200);
myFont = createFont("agency.vlw", 32);
textFont(myFont);
textAlign(CENTER, CENTER);
text("this is text", width/2, height/2);
}
Not quite sure what you mean by "the new font," but how about something like this -- (locations, sizes, colors, etc. of myFont2 could easily be changed, depending on your needs):
PFont myFont1;
PFont myFont2;
void setup()
{
size(200, 200);
myFont1 = createFont("agency.vlw", 32);
myFont2 = createFont("agency.vlw", 16);
textFont(myFont1);
textAlign(CENTER, CENTER);
text("this is text", width/2, height/2);
fill(0);
textFont(myFont2);
textAlign(CENTER, CENTER);
text("this is text", width/3, height/3);
}
Or, maybe something like this?
PFont myFont1;
PFont myFont2;
int x; // x location of myFont2
int y; // y location of myFont2
void setup()
{
y=0;
x=0;
size(200, 200);
myFont1 = createFont("agency.vlw", 32);
myFont2 = createFont("agency.vlw", 16);
}
void draw()
{
for (y = 5; y < height; y=y+30) {
fill(0);
textFont(myFont1);
textAlign(CENTER, CENTER);
text("this is font1", width/2, height/2);
fill(255, 0, 0);
x=x+30;
textFont(myFont2);
textAlign(CENTER, CENTER);
text("this is font2", x, y);
}
y=0;
x=0;
}
This is really a question for the forum. Please post it at: forum.processing.org
Also, this is an archived repo and is no longer monitored. Thanks!