Skip to content

Commit b70a7d0

Browse files
cmagliefacchinm
authored andcommitted
Hi-DPI: tentative auto DPI detection for Linux
See #6472 #4376
1 parent c4f5caf commit b70a7d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arduino-core/src/processing/app/linux/Platform.java

+18
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
import processing.app.PreferencesData;
2626
import processing.app.legacy.PConstants;
2727

28+
import java.awt.Font;
2829
import java.io.File;
2930

31+
import javax.swing.UIManager;
32+
3033

3134
/**
3235
* Used by Base for platform-specific tweaking, for instance finding the
@@ -117,4 +120,19 @@ public void openFolder(File file) throws Exception {
117120
public String getName() {
118121
return PConstants.platformNames[PConstants.LINUX];
119122
}
123+
124+
private int detectedDpi = -1;
125+
126+
@Override
127+
public int getSystemDPI() {
128+
if (detectedDpi != -1)
129+
return detectedDpi;
130+
131+
// we observed that JMenu fonts in java follows the
132+
// System DPI settings, so we compare it to the standard
133+
// font size (12) to obtain a rough estimate of DPI.
134+
Font menuFont = UIManager.getFont("Menu.font");
135+
detectedDpi = menuFont.getSize() * 96 / 12;
136+
return detectedDpi;
137+
}
120138
}

0 commit comments

Comments
 (0)