Skip to content

Commit ce2795a

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] possible wrong zoom set for system font
This commit adapts the initialization of a new base system font in the ScalingSWTFontRegistry to ensure the correct zoom is set at initialization. contributes to #62 and #127
1 parent 99f374d commit ce2795a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ public Font getSystemFont(int zoom) {
9090
private ScaledFontContainer getOrCreateBaseSystemFontContainer(Device device) {
9191
ScaledFontContainer systemFontContainer = fontKeyMap.get(KEY_SYSTEM_FONTS);
9292
if (systemFontContainer == null) {
93-
int targetZoom = DPIUtil.mapDPIToZoom(device.getDPI().x);
94-
long systemFontHandle = createSystemFont(targetZoom);
95-
Font systemFont = Font.win32_new(device, systemFontHandle);
96-
systemFontContainer = new ScaledFontContainer(systemFont, targetZoom);
93+
long hDC = device.internal_new_GC (null);
94+
int dpiX = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX);
95+
device.internal_dispose_GC (hDC, null);
96+
int primaryZoom = DPIUtil.mapDPIToZoom(dpiX);
97+
long systemFontHandle = createSystemFont(primaryZoom);
98+
Font systemFont = Font.win32_new(device, systemFontHandle, primaryZoom);
99+
systemFontContainer = new ScaledFontContainer(systemFont, primaryZoom);
97100
fontHandleMap.put(systemFont.handle, systemFontContainer);
98101
fontKeyMap.put(KEY_SYSTEM_FONTS, systemFontContainer);
99102
}

0 commit comments

Comments
 (0)