Create PDF runtime error with v4.4.7

Creating a pdf of drawing to the screen with beginRecord(PDF, fileName) now gives and error:
“java.lang.RuntimeException: Use createFont() instead of loadFont() when drawing text using the PDF library”
My code uses createFont() and it used to work fine until this update to 4.4.7

1 Like

Hi @Geoffree3 and welcome to the forum!

What is your operating system and could you share a minimal sketch that produces the error?

I tried the following using 4.4.47 on Windows 10 and wasn’t able to reproduce the issue:

import processing.pdf.*;
PFont myFont;

void setup() {
  size(400, 400);
  pixelDensity(1);
  beginRecord(PDF, "everything.pdf");
  myFont = createFont("Georgia", 32);
}

void draw() {
  background(0);
  textFont(myFont);
  textAlign(CENTER, CENTER);
  text("!@#$%", width/2, height/2);
  endRecord();
  exit();
}
import processing.pdf.*;
PFont myFont;

void setup() {
  size(400, 400);
  pixelDensity(1);
  beginRecord(PDF, "everything.pdf");
  myFont = loadFont("AlTarikh-48.vlw");
}

void draw() {
  background(0);
  textFont(myFont);
  textAlign(CENTER, CENTER);
  text("!@#$%", width/2, height/2);
  endRecord();
  exit();
}

I just tried this with 4.3.4 and I get the same error, what version was it still working for you @Geoffree3 ?

I just upgraded to 4.4.7. BTW, the loadFont() will cause an error. createFont(), as in sableraph’s example, should be OK.

The other problem, is that the pdf only includes top left quarter of the processing window, so I have to increase the size dimensions by a factor of 2. e.g. draw a square {square(0,0,1000)} needs size(2000, 2000). I’m using an iMac.

Add pixelDensity(1) to your void setup(){ we’re adding a notice for that in 4.4.8!

Many thanks. Solved the pdf scaling problem.

Hello @stefterv,

Can we also add an entry to the Wiki about this:

The Troubleshooting section would be a good spot for it.

:)

1 Like