From 0c835767d6b66962fb122f58a07e294ccd9f77ed Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Mon, 11 Aug 2025 11:54:35 +0200 Subject: [PATCH] [Win32] Fix wrong line height in StyledText #2405 The line height in StyledText is currently too large when the auto-scaled device zoom is larger than the native zoom. This for example happens on a 175% primary monitor with `swt.autoScale=int200` or with a fixed `swt.autoScale` value that is higher than the primary monitor zoom. This was caused by a recent change that accidentally used the auto-scaled zoom instead of the native zoom for retrieving a font handle combined with the general usage of the ScalingSWTFontRegistry that, in comparison to the previous fixed-zoom registry, now returns an accordingly scaled handle. This change adapts the font handle retrieval to properly pass the native zoom instead of the auto-scaled zoom. Fixes https://github.com/eclipse-platform/eclipse.platform.swt/issues/2405 --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java index a01a5f881d9..56f6550e987 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java @@ -2135,7 +2135,7 @@ public FontMetrics getLineMetrics (int lineIndex) { long srcHdc = OS.CreateCompatibleDC(hDC); TEXTMETRIC lptm = new TEXTMETRIC(); final int zoom = getZoom(); - long availableFont = font != null ? SWTFontProvider.getFontHandle(font, zoom) : SWTFontProvider.getSystemFontHandle(device, zoom); + long availableFont = font != null ? SWTFontProvider.getFontHandle(font, nativeZoom) : SWTFontProvider.getSystemFontHandle(device, nativeZoom); OS.SelectObject(srcHdc, availableFont); metricsAdapter.GetTextMetrics(srcHdc, lptm); OS.DeleteDC(srcHdc);