Skip to content

Commit 7f48053

Browse files
committed
Merge pull request processing#4506 from JakubValtar/npe-createfont
Give helpful message when createFont() called before setup()
2 parents 9bafe4c + 0ca631d commit 7f48053

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,6 +6178,10 @@ public PFont createFont(String name, float size, boolean smooth) {
61786178
*/
61796179
public PFont createFont(String name, float size,
61806180
boolean smooth, char[] charset) {
6181+
if (g == null) {
6182+
System.err.println("The sketch is not initialized yet.");
6183+
throw new RuntimeException("Fonts must be created inside setup() or after it has been called.");
6184+
}
61816185
return g.createFont(name, size, smooth, charset);
61826186
}
61836187

0 commit comments

Comments
 (0)