Why isn't the font chosen in the pdf that is exported?

import processing.pdf.*;
PGraphicsPDF pdf;


PFont font;
String s="NOT THE ACTUAL EVENTS";

void setup(){
  size(400,600);
  font=createFont("Programme-RegularAlt",10);
  textFont(font);
  //fill(0);
  frameRate(30);
  pdf = (PGraphicsPDF)beginRecord(PDF, "nin.pdf");
  beginRecord(pdf);
}

void draw(){
    textMode(SHAPE);
  //background(255);
  fill(255,255);
  rect(0,0,width,height);
  fill(0);
  text(s,random(0, 400),random(0,600));
   pdf.nextPage();
    
    for (int i=0; i<100; i++) {
    float r = random(1.0);
    if(r < 1) {
      text(1,0,0); 
    } else {
      text(0,0,0); 
    }
}


 if(frameCount == 30 ) {
    endRecord();
    exit();  // Quit
  } else {
    pdf.nextPage();  // Tell it to go to the next page 
  }
}

You have to specify the renderer for textFont()

void setup(){
  size(400,600);
  font=createFont("Comic Sans MS",10);
  //fill(0);
  frameRate(30);
  pdf = (PGraphicsPDF)beginRecord(PDF, "nin.pdf");
  pdf.textFont(font);
  beginRecord(pdf);
}
1 Like