From 7bf9b0aceff57d9bd6924383037356ca21144707 Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Thu, 31 Oct 2024 08:54:14 +0100 Subject: [PATCH] [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 --- .../eclipse/swt/internal/ScalingSWTFontRegistry.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java index 0fd4b9aec2e..dc74eaeb017 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java @@ -90,10 +90,13 @@ public Font getSystemFont(int zoom) { private ScaledFontContainer getOrCreateBaseSystemFontContainer(Device device) { ScaledFontContainer systemFontContainer = fontKeyMap.get(KEY_SYSTEM_FONTS); if (systemFontContainer == null) { - int targetZoom = DPIUtil.mapDPIToZoom(device.getDPI().x); - long systemFontHandle = createSystemFont(targetZoom); - Font systemFont = Font.win32_new(device, systemFontHandle); - systemFontContainer = new ScaledFontContainer(systemFont, targetZoom); + long hDC = device.internal_new_GC (null); + int dpiX = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX); + device.internal_dispose_GC (hDC, null); + int primaryZoom = DPIUtil.mapDPIToZoom(dpiX); + long systemFontHandle = createSystemFont(primaryZoom); + Font systemFont = Font.win32_new(device, systemFontHandle, primaryZoom); + systemFontContainer = new ScaledFontContainer(systemFont, primaryZoom); fontHandleMap.put(systemFont.handle, systemFontContainer); fontKeyMap.put(KEY_SYSTEM_FONTS, systemFontContainer); }