Why TTF fonts don't load properly with me in javascript Mode?

edited March 2014 in JavaScript Mode

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

image alt text

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 :)

Tagged:

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.

  • edited March 2014

    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:///

Sign In or Register to comment.