We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I tried the example code offered by processing js, but the TTF font still doesn't load properly Here is my code
/* @pjs font="automat.ttf"; */
void setup()
{
size(200,200);
noLoop();
textFont(createFont("automat",32));
}
void draw()
{
background(255);
String t = "P.js";
float tw = textWidth(t);
fill(0);
text(t, (width-tw)/2, (height+32)/2);
}
And the outcome is like this
Here is the TTF file that I used https://drive.google.com/file/d/0BwrY_kn-ktHEN3hOcXNwZDJkSkE/edit?u...
I don't know why this doesn't work.... Any one can get the font working in javascript mode? I would be very grateful if you can tell me your way of loading fonts :)
Answers
Are you testing it in a Web site?
Yes, I am.
Is it public?
Thinking of it, shouldn't you write:
createFont("automat.ttf",32)
Processing (non-JS, at least), requires the file extension when you load a file not installed on the system.
Oh. Finally get it working. Thanks
I tried your code, and it didn't work. I added .ttf to the font name in createFont(), and it worked. With PJS 1.4.1, in Firefox and Chrome, from a local server, and even as file:///