attempt to set ui scale on sketch startup (working on #378)

This commit is contained in:
Ben Fry
2022-02-12 12:12:08 -05:00
parent ee0f093981
commit 6c2209a439
+11
View File
@@ -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