Skip to content

Commit ce0609f

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Font zoom calculation device independent
This commit ensures the zoom calculation for a device is device independent again. 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 97f8a2e commit ce0609f

File tree

1 file changed

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

1 file changed

+6
-13
lines changed

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

+6-13
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 = DPIUtil.getNativeDeviceZoom();
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 = DPIUtil.getNativeDeviceZoom();
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 = DPIUtil.getNativeDeviceZoom();
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 = DPIUtil.getNativeDeviceZoom();
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 = DPIUtil.getNativeDeviceZoom();
193193
init(new FontData (name, height, style));
194194
this.fontHeight = height;
195195
init();
@@ -294,13 +294,6 @@ public String toString () {
294294
return "Font {" + handle + "}";
295295
}
296296

297-
private static int extractZoom(Device device) {
298-
if (device == null) {
299-
return DPIUtil.getNativeDeviceZoom();
300-
}
301-
return device.getDeviceZoom();
302-
}
303-
304297
/**
305298
* Invokes platform specific functionality to allocate a new font.
306299
* <p>
@@ -318,7 +311,7 @@ private static int extractZoom(Device device) {
318311
* @noreference This method is not intended to be referenced by clients.
319312
*/
320313
public static Font win32_new(Device device, long handle) {
321-
int zoom = extractZoom(device);
314+
int zoom = DPIUtil.getNativeDeviceZoom();
322315
return win32_new(device, handle, zoom);
323316
}
324317

0 commit comments

Comments
 (0)