Skip to content

Commit 3b48711

Browse files
committed
Fix High DPI scaling on some Macs with Retina Display
Also: Print OS Name and Version to Console Log on app start
1 parent bfb87e6 commit 3b48711

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Revisit Ganglion Impedance widget so it behaves like new Cyton Impedance Widget #1021
66
* Fix dropdown backgrounds in Networking Widget
77
* Update priveleges for Windows users and check if GUI has been run as Administrator
8+
* Fix High DPI scaling on some Macs with Retina Display
89

910
### Improvements
1011
* Add new FilterUI to allow custom filters per channel #988
@@ -22,6 +23,7 @@
2223
* Fix certain Textfield and TextArea fonts not drawing correctly on some Macs
2324
* Update and enforce style guide throughout the GUI in preparation for multiple themes
2425
* Improve UI/UX for HelpWidget at the bottom of the GUI to make it more noticeable
26+
* Print OS Name and Version to Console Log on app start
2527

2628
# v5.0.9
2729

OpenBCI_GUI/Extras.pde

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,41 @@ private boolean isMac() {
3232
return !isWindows() && !isLinux();
3333
}
3434

35+
// For a full list of modern Mac OS versions, visit https://en.wikipedia.org/wiki/MacOS_version_history
36+
private boolean isMacOsLowerThanCatalina() {
37+
int[] versionInfo = fetchAndParseMacOsVersion();
38+
return versionInfo[0] <= 10 && versionInfo[1] < 15;
39+
}
40+
41+
private boolean isMacOsBigSur() {
42+
int[] versionInfo = fetchAndParseMacOsVersion();
43+
return versionInfo[0] == 11;
44+
}
45+
46+
private boolean isMacOsMonterey() {
47+
int[] versionInfo = fetchAndParseMacOsVersion();
48+
return versionInfo[0] == 12;
49+
}
50+
51+
private String getOperatingSystemVersion() {
52+
return System.getProperty("os.version");
53+
}
54+
55+
private int[] fetchAndParseMacOsVersion() {
56+
if (!isMac()) {
57+
println("Oops! Please only call this method on MacOS");
58+
return null;
59+
}
60+
61+
final String version = getOperatingSystemVersion();
62+
final String[] splitStrings = split(version, '.');
63+
int[] versionVals = new int[splitStrings.length];
64+
for (int i = 0; i < splitStrings.length; i++) {
65+
versionVals[i] = Integer.valueOf(splitStrings[i]);
66+
}
67+
return versionVals;
68+
}
69+
3570
//BrainFlow only supports Windows 8 and 10. This will help with OpenBCI support tickets. #964
3671
private void checkIsOldVersionOfWindowsOS() {
3772
boolean isOld = SystemUtils.IS_OS_WINDOWS_7 || SystemUtils.IS_OS_WINDOWS_VISTA || SystemUtils.IS_OS_WINDOWS_XP;

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ void settings() {
337337
globalScreenResolution.append(" X ");
338338
globalScreenResolution.append(displayHeight);
339339
//Account for high-dpi displays on Mac, Windows, and Linux Machines Fixes #968
340-
if (isMac())
341-
//pixelDensity(displayDensity());
340+
pixelDensity(displayDensity());
342341
globalScreenDPI = new StringBuilder("High-DPI Screen Detected: ");
343342
globalScreenDPI.append(displayDensity() == 2);
344343
}
@@ -350,7 +349,11 @@ void setup() {
350349

351350
//V1 FONTS
352351
f1 = createFont("fonts/Raleway-SemiBold.otf", 16);
353-
f2 = createFont("fonts/Raleway-Regular.otf", 15);
352+
if (isMac() && isMacOsLowerThanCatalina() && (displayDensity() > 1)) {
353+
f2 = createFont("fonts/Raleway-Regular.otf", 9);
354+
} else {
355+
f2 = createFont("fonts/Raleway-Regular.otf", 15);
356+
}
354357
f3 = createFont("fonts/Raleway-SemiBold.otf", 15);
355358
f4 = createFont("fonts/Raleway-SemiBold.otf", 64); // clear bigger fonts for widgets
356359

@@ -391,7 +394,7 @@ void setup() {
391394
System.setOut(outputStream);
392395
System.setErr(outputStream);
393396

394-
StringBuilder osName = new StringBuilder("Operating System: ");
397+
StringBuilder osName = new StringBuilder("Operating System and Version: ");
395398
if (isLinux()) {
396399
osName.append("Linux");
397400
} else if (isWindows()) {
@@ -404,6 +407,9 @@ void setup() {
404407
osName.append("Mac");
405408
}
406409

410+
osName.append(" - ");
411+
osName.append(getOperatingSystemVersion());
412+
407413
println("Console Log Started at Local Time: " + directoryManager.getFileNameDateTime());
408414
println(globalScreenResolution.toString());
409415
println(globalScreenDPI.toString());

0 commit comments

Comments
 (0)