diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/LegacySWTFontRegistryTests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java similarity index 96% rename from bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/LegacySWTFontRegistryTests.java rename to bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java index 80851f9b653..4dcaead797c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/LegacySWTFontRegistryTests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java @@ -23,16 +23,15 @@ import org.junit.jupiter.api.extension.*; @ExtendWith(PlatformSpecificExecutionExtension.class) -class LegacySWTFontRegistryTests { +class DefaultSWTFontRegistryTests { private static String TEST_FONT = "Helvetica"; private Display display; private SWTFontRegistry fontRegistry; - @SuppressWarnings("removal") @BeforeEach public void setUp() { this.display = Display.getDefault(); - this.fontRegistry = new LegacySWTFontRegistry(display); + this.fontRegistry = new DefaultSWTFontRegistry(display); } @AfterEach diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java index 3da919d191b..a7b9c8de7c8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java @@ -35,7 +35,7 @@ class ControlWin32Tests { @Test - public void testScaleFontCorrectlyInAutoScaleScenario() { + public void testScaleFontCorrectlyInAutoScaleSzenario() { DPIUtil.setMonitorSpecificScaling(true); Display display = Display.getDefault(); @@ -58,37 +58,15 @@ public void testSetFontWithMonitorSpecificScalingEnabled() { } @Test - public void testScaleFontCorrectlyInNoAutoScaleScenario() { + public void testDoNotScaleFontCorrectlyInNoAutoScaleSzenario() { DPIUtil.setMonitorSpecificScaling(false); Display display = Display.getDefault(); assertFalse("Autoscale property is not set to false", display.isRescalingAtRuntime()); int scalingFactor = 2; FontComparison fontComparison = updateFont(scalingFactor); - assertEquals("Font height in pixels is not adjusted according to the scale factor", - fontComparison.originalFontHeight * scalingFactor, fontComparison.currentFontHeight); - } - - @Test - public void testDoNotScaleFontInNoAutoScaleScenarioWithLegacyFontRegistry() { - DPIUtil.setMonitorSpecificScaling(false); - String originalValue = System.getProperty("swt.fontRegistry"); - System.setProperty("swt.fontRegistry", "legacy"); - try { - Display display = Display.getDefault(); - - assertFalse("Autoscale property is not set to false", display.isRescalingAtRuntime()); - int scalingFactor = 2; - FontComparison fontComparison = updateFont(scalingFactor); - assertEquals("Font height in pixels is different when setting the same font again", - fontComparison.originalFontHeight, fontComparison.currentFontHeight); - } finally { - if (originalValue != null) { - System.setProperty("swt.fontRegistry", originalValue); - } else { - System.clearProperty("swt.fontRegistry"); - } - } + assertEquals("Font height in pixels is different when setting the same font again", + fontComparison.originalFontHeight, fontComparison.currentFontHeight); } @Test 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 4b0c4785994..cd4f197b702 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 @@ -5725,7 +5725,7 @@ void apply() { */ public Point stringExtent (String string) { if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return Win32DPIUtils.pixelToPoint(drawable, stringExtentInPixels(string), data.font.zoom); + return Win32DPIUtils.pixelToPoint(drawable, stringExtentInPixels(string), getZoom()); } Point stringExtentInPixels (String string) { @@ -5805,7 +5805,7 @@ public Point textExtent (String string) { * */ public Point textExtent (String string, int flags) { - return Win32DPIUtils.pixelToPoint(drawable, textExtentInPixels(string, flags), data.font.zoom); + return Win32DPIUtils.pixelToPoint(drawable, textExtentInPixels(string, flags), getZoom()); } Point textExtentInPixels(String string, int flags) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/LegacySWTFontRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java similarity index 83% rename from bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/LegacySWTFontRegistry.java rename to bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java index f1e287a4b00..222080e765b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/LegacySWTFontRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java @@ -19,25 +19,19 @@ import org.eclipse.swt.internal.win32.*; /** - *

- * Formerly {@code DefaultSWTFontRegistry}, this class is deprecated. Use {@code ScalingSWTFontRegistry} instead. - * To temporarily fall back to legacy font behavior ({@code LegacySWTFontRegistry}) - * (e.g., if issues arise in existing RCP products), set the system property: {@code - * -Dswt.fontRegistry=legacy - * } - *

+ * This class is used in the win32 implementation only to support + * unscaled fonts in multiple DPI zoom levels. * * As this class is only intended to be used internally via {@code SWTFontProvider}, * it should neither be instantiated nor referenced in a client application. * The behavior can change any time in a future release. */ -@Deprecated(forRemoval= true, since= "2025-09") -final class LegacySWTFontRegistry implements SWTFontRegistry { +final class DefaultSWTFontRegistry implements SWTFontRegistry { private static FontData KEY_SYSTEM_FONTS = new FontData(); private Map fontsMap = new HashMap<>(); private Device device; - LegacySWTFontRegistry(Device device) { + DefaultSWTFontRegistry(Device device) { this.device = device; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/SWTFontProvider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/SWTFontProvider.java index 7312a5acb20..6addde3c985 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/SWTFontProvider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/SWTFontProvider.java @@ -108,15 +108,10 @@ public static void disposeFontRegistry(Device device) { } } - private static final String SWT_FONT_REGISTRY = "swt.fontRegistry"; - - @SuppressWarnings("removal") private static SWTFontRegistry newFontRegistry(Device device) { - if ("legacy".equalsIgnoreCase(System.getProperty(SWT_FONT_REGISTRY)) && device instanceof Display display - && !display.isRescalingAtRuntime()) { - return new LegacySWTFontRegistry(device); + if (device instanceof Display display && display.isRescalingAtRuntime()) { + return new ScalingSWTFontRegistry(device); } - return new ScalingSWTFontRegistry(device); - + return new DefaultSWTFontRegistry(device); } }