Skip to content

Commit 574cfef

Browse files
committed
[win32] Make Font#extractZoom device independent
This commit ensures Font#extractZoom is device independent. The previous logic didn't provide any advantages anymore after the conversion between points and pixels was changed for Fonts. By using DPIUtil#getNativeZoom the most probable value for the zoom of a new font a chosen.
1 parent 329ed24 commit 574cfef

File tree

1 file changed

+7
-7
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+7
-7
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class Font extends Resource {
6767
*/
6868
Font(Device device) {
6969
super(device);
70-
this.zoom = extractZoom(this.device);
70+
this.zoom = extractZoom(device);
7171
this.fontHeight = 0;
7272
}
7373

@@ -100,7 +100,7 @@ private Font(Device device, long handle, int zoom) {
100100
*/
101101
public Font(Device device, FontData fd) {
102102
super(device);
103-
this.zoom = extractZoom(this.device);
103+
this.zoom = extractZoom(device);
104104
init(fd);
105105
this.fontHeight = fd.height;
106106
init();
@@ -146,7 +146,7 @@ public Font(Device device, FontData[] fds) {
146146
for (FontData fd : fds) {
147147
if (fd == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
148148
}
149-
this.zoom = extractZoom(this.device);
149+
this.zoom = extractZoom(device);
150150
FontData fd = fds[0];
151151
init(fds[0]);
152152
this.fontHeight = fd.height;
@@ -180,7 +180,7 @@ public Font(Device device, FontData[] fds) {
180180
public Font(Device device, String name, int height, int style) {
181181
super(device);
182182
if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
183-
this.zoom = extractZoom(this.device);
183+
this.zoom = extractZoom(device);
184184
init(new FontData (name, height, style));
185185
this.fontHeight = height;
186186
init();
@@ -189,7 +189,7 @@ public Font(Device device, String name, int height, int style) {
189189
/*public*/ Font(Device device, String name, float height, int style) {
190190
super(device);
191191
if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
192-
this.zoom = extractZoom(this.device);
192+
this.zoom = extractZoom(device);
193193
init(new FontData (name, height, style));
194194
this.fontHeight = height;
195195
init();
@@ -296,9 +296,9 @@ public String toString () {
296296

297297
private static int extractZoom(Device device) {
298298
if (device == null) {
299-
return DPIUtil.getNativeDeviceZoom();
299+
System.out.println ("***WARNING: Initializing a font with a null device will use the default device and can lead to errors when this font is used with another device."); //$NON-NLS-1$
300300
}
301-
return device.getDeviceZoom();
301+
return DPIUtil.getNativeDeviceZoom();
302302
}
303303

304304
/**

0 commit comments

Comments
 (0)