Skip to content

Commit b7d4598

Browse files
committed
Removal for OS.LOGPIXELS* in FontDialog #62
This commit removes the usage of OS.LOGPIXELS* in FontDialog. These values can be obtained using other means as the OS.LOGPIXELS provides the dpi values of the primary monitor at the app-startup time. It's usage has been replaced by passing the zoom directly in FontDialog::open method. contributes to #62 and #127
1 parent 6171056 commit b7d4598

File tree

1 file changed

+4
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+4
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import org.eclipse.swt.*;
1818
import org.eclipse.swt.graphics.*;
19+
import org.eclipse.swt.internal.*;
1920
import org.eclipse.swt.internal.win32.*;
2021

2122
/**
@@ -195,14 +196,13 @@ public FontData open () {
195196
if (effectsVisible) {
196197
lpcf.Flags |= OS.CF_EFFECTS;
197198
}
199+
int dpi = DPIUtil.mapZoomToDPI(getParent().nativeZoom);
198200

199201
long lpLogFont = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, LOGFONT.sizeof);
200202
if (fontData != null && fontData.data != null) {
201203
LOGFONT logFont = fontData.data;
202204
int lfHeight = logFont.lfHeight;
203-
long hDC = OS.GetDC (0);
204-
int pixels = -(int)(0.5f + (fontData.height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72));
205-
OS.ReleaseDC (0, hDC);
205+
int pixels = -(int)(0.5f + (fontData.height * dpi / 72));
206206
logFont.lfHeight = pixels;
207207
lpcf.Flags |= OS.CF_INITTOLOGFONTSTRUCT;
208208
OS.MoveMemory (lpLogFont, logFont, LOGFONT.sizeof);
@@ -257,7 +257,7 @@ public FontData open () {
257257
* proper device.
258258
*/
259259
long hDC = OS.GetDC(0);
260-
int logPixelsY = OS.GetDeviceCaps(hDC, OS.LOGPIXELSY);
260+
int logPixelsY = dpi;
261261
int pixels = 0;
262262
if (logFont.lfHeight > 0) {
263263
/*

0 commit comments

Comments
 (0)