Skip to content

Commit

Permalink
Hi-DPI: tentative auto DPI detection for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie authored and facchinm committed Sep 28, 2017
1 parent 0769e8a commit b771467
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions arduino-core/src/processing/app/linux/Platform.java
Expand Up @@ -25,8 +25,11 @@
import processing.app.PreferencesData;
import processing.app.legacy.PConstants;

import java.awt.Font;
import java.io.File;

import javax.swing.UIManager;


/**
* Used by Base for platform-specific tweaking, for instance finding the
Expand Down Expand Up @@ -117,4 +120,19 @@ public void openFolder(File file) throws Exception {
public String getName() {
return PConstants.platformNames[PConstants.LINUX];
}

private int detectedDpi = -1;

@Override
public int getSystemDPI() {
if (detectedDpi != -1)
return detectedDpi;

// we observed that JMenu fonts in java follows the
// System DPI settings, so we compare it to the standard
// font size (12) to obtain a rough estimate of DPI.
Font menuFont = UIManager.getFont("Menu.font");
detectedDpi = menuFont.getSize() * 96 / 12;
return detectedDpi;
}
}

0 comments on commit b771467

Please sign in to comment.