Merge pull request #4506 from JakubValtar/npe-createfont

Give helpful message when createFont() called before setup()
This commit is contained in:
Ben Fry
2016-06-02 16:35:32 -04:00
+4
View File
@@ -6178,6 +6178,10 @@ public class PApplet implements PConstants {
*/
public PFont createFont(String name, float size,
boolean smooth, char[] charset) {
if (g == null) {
System.err.println("The sketch is not initialized yet.");
throw new RuntimeException("Fonts must be created inside setup() or after it has been called.");
}
return g.createFont(name, size, smooth, charset);
}