We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi There
I am using the next code to have a Font List. It works perfectly. But i want to replace the ''random(0, 2)" by the sequence of the font list. So, i want that the font is not anymore random. Do someone know how i can fix this?
Greetings
PFont afont, bfont, cfont;
String[]mainfont = {"afont", "bfont", "cfont"};
void setup() { size(200,200);
afont = createFont("FreeMono", 1); bfont = createFont("Kinnari-Italic", 1); cfont = createFont("Norasi", 1);
}
void draw(){
float x = random(0,2); int y = int (x);
textFont(mainfont[y]);
// GET THE MESSAGE: method textFont(PFont) in the type PApplet is // not applicable for the arguments (String)
text("I want to get here everytime another FONTtype", 50, 50); }
Answers
float x=1;
Or
int x=1;
Sequence for loop ( See Reference)
Thanks, but to be more specific, i want in the font sequence that each font (e) is 200 pixels to the bottom.
you're using
which you can't loop over. you really want an array of PFont.
thanks :)
you are welcome!
;-)
general it is not good to use createFont outside setup - I just did that here because I use noLoop() anyway
alternatively, have a 2nd array of the fonts (
PFont[] fontListOfPFont;
) and set it up in setup() and use it in draw()Can you suggest me how i can connect this with an array font list that i set in a local folder
what is this
?
do you mean the fonts you have in the folder (ttf / vlw files) or a text file with a list in it?
i want to make an array font list with selected fonts. The question is how i can connect it with an arrray list like below
afont = createFont("FreeMono", 1); bfont = createFont("Kinnari-Italic", 1); cfont = createFont("Norasi", 1);
replace line 1 with
then like above but without the line 5