Skip to content

Hi-DPI: tentative auto DPI detection for Linux #6531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions arduino-core/src/processing/app/linux/Platform.java
Original file line number Diff line number Diff line change
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;
}
}