CreateFont() giving NullPointerException in Eclipse

Hi!

I am using processing in eclipse and I am trying to use CreateFont(), but I keep getting a NullPointerException.

This is my code;

private InfoPanel() {
    File font = new File("src\\cour.ttf");
    String str = font.getAbsolutePath();
    infoFont = p.createFont("src/cour.ttf", 12, false);
}

Where 'p' is the main PApplet.

What I have already done;

  • Tried switching between using '/' and '\' in the path
  • Tried using str as name
  • Ensured "cour.ttf" is in the 'src' folder
  • Tried "cour.ttf" being in 'data' folder both inside and outside 'src'

Originally I wanted to use loadFont() instead but that did not work either (Have done the same with it as the list above).

It should also be noted that;

  • The constructor is private as a path of being a singleton
  • The class in question import PApplet, but does not import it (thus the 'p.');

Any help is welcome, thank you.

Answers

Sign In or Register to comment.