diff -r 0cb361dfbd33 modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java --- a/modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java Thu Nov 16 15:48:08 2017 -0800 +++ b/modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java Tue Nov 21 20:42:17 2017 +0100 @@ -186,6 +186,17 @@ } catch (Exception e) { // FAIL silently should the reflection fail } + } else if( SWT.getPlatform().equals("win32") ) { + if( swtDPIUtilMethod == null ) { + return 1.0; + } + + try { + Integer value = (Integer) swtDPIUtilMethod.invoke(null); + return value.intValue() / 100.0; + } catch (Exception e) { + // FAIL silently should the reflection fail + } } return 1.0; } @@ -228,6 +239,8 @@ private static Method screenMethod; private static Method backingScaleFactorMethod; + private static Method swtDPIUtilMethod; + static { if (SWT.getPlatform().equals("cocoa")) { try { @@ -248,6 +261,16 @@ } catch (Exception e) { //Fail silently. If we can't get the methods, then the current version of SWT has no retina support } + } else if( SWT.getPlatform().equals("win32") ) { + try { + if( System.getProperty("swt.autoScale") == null || Boolean.getBoolean("swt.autoScale") ) { + Class dpiUtilClass = Class.forName("org.eclipse.swt.internal.DPIUtil"); + swtDPIUtilMethod = dpiUtilClass.getMethod("getDeviceZoom"); + } + } catch (Exception e) { + //Fail silently. If we can't get the methods, then the current version of SWT has no retina support + } + } } @@ -266,8 +289,19 @@ private static void initFx() { AccessController.doPrivileged((PrivilegedAction) () -> { System.setProperty("javafx.embed.isEventThread", "true"); - System.setProperty("glass.win.uiScale", "100%"); - System.setProperty("glass.win.renderScale", "100%"); + if( swtDPIUtilMethod == null ) { + System.setProperty("glass.win.uiScale", "100%"); + System.setProperty("glass.win.renderScale", "100%"); + } else { + Integer scale = 100; + try { + scale = (Integer) swtDPIUtilMethod.invoke(null); + } catch (Exception e) { + //Fail silently + } + System.setProperty("glass.win.uiScale", scale + "%"); + System.setProperty("glass.win.renderScale", scale + "%"); + } return null; }); Map map = Application.getDeviceDetails();