From 6c2209a4396bdac0f8abeb332eb6b4ece53c4063 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 12 Feb 2022 12:12:08 -0500 Subject: [PATCH] attempt to set ui scale on sketch startup (working on #378) --- core/src/processing/core/PApplet.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 5b08f73b5..8643ab9a4 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -10181,6 +10181,17 @@ public class PApplet implements PConstants { uncaughtThrowable = e; }); + if (platform == WINDOWS) { + // Set DPI scaling to either 1 or 2, but avoid fractional versions like + // 125% and 250% that make things look gross, or even 300% since that + // is not even a thing. + int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution(); + System.out.println("dpi came back " + dpi); + int scaleFactor = constrain(dpi / 96, 1, 2); + System.out.println("setting scale factor to " + scaleFactor); + System.setProperty("sun.java2d.uiscale", String.valueOf(scaleFactor)); + } + // This doesn't work, need to mess with Info.plist instead /* // In an exported application, add the Contents/Java folder to the