diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 4136c51b2..e766a2f8d 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1120,6 +1120,7 @@ public class PApplet implements PConstants { return 1; } } + // If nobody's density is 1 (or != 2, to be exact) then everyone is 2 return 2; } return displayDensity(display); @@ -1153,7 +1154,7 @@ public class PApplet implements PConstants { System.err.println("Only one display is currently known, use displayDensity(1)."); } else { System.err.format("Your displays are numbered %d through %d, " + - "pass one of those numbers to displayDensity()", 1, devices.length); + "pass one of those numbers to displayDensity()%n", 1, devices.length); } throw new RuntimeException("Display " + display + " does not exist."); } diff --git a/java/src/processing/mode/java/preproc/PdePreprocessor.java b/java/src/processing/mode/java/preproc/PdePreprocessor.java index 89d4c775c..9b0533b06 100644 --- a/java/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/java/src/processing/mode/java/preproc/PdePreprocessor.java @@ -329,6 +329,11 @@ public class PdePreprocessor { String[] pixelDensityContents = matchMethod("pixelDensity", searchArea); if (pixelDensityContents != null) { extraStatements.append(pixelDensityContents[0]); + } else { + pixelDensityContents = matchDensityMess(searchArea); + if (pixelDensityContents != null) { + extraStatements.append(pixelDensityContents[0]); + } } String[] sizeContents = matchMethod("size", searchArea); @@ -433,6 +438,13 @@ public class PdePreprocessor { } + static protected String[] matchDensityMess(String searchArea) { + final String regexp = + "(?:^|\\s|;)pixelDensity\\s*\\(\\s*displayDensity\\s*\\([^\\)]*\\)\\s*\\)\\s*\\;"; + return PApplet.match(searchArea, regexp); + } + + /** * Replace all commented portions of a given String as spaces. * Utility function used here and in the preprocessor.