Skip to content

Commit 0ca631d

Browse files
committed
Give helpful message when createFont() called before setup()
Fixes processing#4486
1 parent b4882e1 commit 0ca631d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)