From ad550fe1d1cdb4bbe507a4b93631b38b33b0095c Mon Sep 17 00:00:00 2001 From: arunjose696 Date: Thu, 10 Jul 2025 14:35:26 +0200 Subject: [PATCH] Use font zoom in stringExtent and textExtent Previously, stringExtent calculated the width of a string in pixels using GC.getZoom(), which could lead to inconsistencies if the provided font had a different zoom level. This change ensures that the pixels-to-points conversion uses the zoom of the specified font. --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index e61fa23614f..ead395517d4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -5644,7 +5644,7 @@ void apply() { */ public Point stringExtent (String string) { if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return DPIUtil.scaleDown(drawable, stringExtentInPixels(string), getZoom()); + return DPIUtil.scaleDown(drawable, stringExtentInPixels(string), data.font.zoom); } Point stringExtentInPixels (String string) { @@ -5724,7 +5724,7 @@ public Point textExtent (String string) { * */ public Point textExtent (String string, int flags) { - return DPIUtil.scaleDown(drawable, textExtentInPixels(string, flags), getZoom()); + return DPIUtil.scaleDown(drawable, textExtentInPixels(string, flags), data.font.zoom); } Point textExtentInPixels(String string, int flags) {