Skip to content

Commit 08653e1

Browse files
committed
Revert "Deprecate DefaultSWTFontRegistry and switch to ScalingSWTFontRegistry"
This reverts commit a413b4b.
1 parent 74feaa5 commit 08653e1

File tree

4 files changed

+13
-47
lines changed

4 files changed

+13
-47
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@
2323
import org.junit.jupiter.api.extension.*;
2424

2525
@ExtendWith(PlatformSpecificExecutionExtension.class)
26-
class LegacySWTFontRegistryTests {
26+
class DefaultSWTFontRegistryTests {
2727
private static String TEST_FONT = "Helvetica";
2828
private Display display;
2929
private SWTFontRegistry fontRegistry;
3030

31-
@SuppressWarnings("removal")
3231
@BeforeEach
3332
public void setUp() {
3433
this.display = Display.getDefault();
35-
this.fontRegistry = new LegacySWTFontRegistry(display);
34+
this.fontRegistry = new DefaultSWTFontRegistry(display);
3635
}
3736

3837
@AfterEach

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class ControlWin32Tests {
3636

3737
@Test
38-
public void testScaleFontCorrectlyInAutoScaleScenario() {
38+
public void testScaleFontCorrectlyInAutoScaleSzenario() {
3939
DPIUtil.setMonitorSpecificScaling(true);
4040
Display display = Display.getDefault();
4141

@@ -58,37 +58,15 @@ public void testSetFontWithMonitorSpecificScalingEnabled() {
5858
}
5959

6060
@Test
61-
public void testScaleFontCorrectlyInNoAutoScaleScenario() {
61+
public void testDoNotScaleFontCorrectlyInNoAutoScaleSzenario() {
6262
DPIUtil.setMonitorSpecificScaling(false);
6363
Display display = Display.getDefault();
6464

6565
assertFalse("Autoscale property is not set to false", display.isRescalingAtRuntime());
6666
int scalingFactor = 2;
6767
FontComparison fontComparison = updateFont(scalingFactor);
68-
assertEquals("Font height in pixels is not adjusted according to the scale factor",
69-
fontComparison.originalFontHeight * scalingFactor, fontComparison.currentFontHeight);
70-
}
71-
72-
@Test
73-
public void testDoNotScaleFontInNoAutoScaleScenarioWithLegacyFontRegistry() {
74-
DPIUtil.setMonitorSpecificScaling(false);
75-
String originalValue = System.getProperty("swt.fontRegistry");
76-
System.setProperty("swt.fontRegistry", "legacy");
77-
try {
78-
Display display = Display.getDefault();
79-
80-
assertFalse("Autoscale property is not set to false", display.isRescalingAtRuntime());
81-
int scalingFactor = 2;
82-
FontComparison fontComparison = updateFont(scalingFactor);
83-
assertEquals("Font height in pixels is different when setting the same font again",
84-
fontComparison.originalFontHeight, fontComparison.currentFontHeight);
85-
} finally {
86-
if (originalValue != null) {
87-
System.setProperty("swt.fontRegistry", originalValue);
88-
} else {
89-
System.clearProperty("swt.fontRegistry");
90-
}
91-
}
68+
assertEquals("Font height in pixels is different when setting the same font again",
69+
fontComparison.originalFontHeight, fontComparison.currentFontHeight);
9270
}
9371

9472
@Test
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@
1919
import org.eclipse.swt.internal.win32.*;
2020

2121
/**
22-
* <p>
23-
* Formerly {@code DefaultSWTFontRegistry}, this class is deprecated. Use {@code ScalingSWTFontRegistry} instead.
24-
* To temporarily fall back to legacy font behavior ({@code LegacySWTFontRegistry})
25-
* (e.g., if issues arise in existing RCP products), set the system property: {@code
26-
* -Dswt.fontRegistry=legacy
27-
* }
28-
* </p>
22+
* This class is used in the win32 implementation only to support
23+
* unscaled fonts in multiple DPI zoom levels.
2924
*
3025
* As this class is only intended to be used internally via {@code SWTFontProvider},
3126
* it should neither be instantiated nor referenced in a client application.
3227
* The behavior can change any time in a future release.
3328
*/
34-
@Deprecated(forRemoval= true, since= "2025-09")
35-
final class LegacySWTFontRegistry implements SWTFontRegistry {
29+
final class DefaultSWTFontRegistry implements SWTFontRegistry {
3630
private static FontData KEY_SYSTEM_FONTS = new FontData();
3731
private Map<FontData, Font> fontsMap = new HashMap<>();
3832
private Device device;
3933

40-
LegacySWTFontRegistry(Device device) {
34+
DefaultSWTFontRegistry(Device device) {
4135
this.device = device;
4236
}
4337

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,10 @@ public static void disposeFontRegistry(Device device) {
108108
}
109109
}
110110

111-
private static final String SWT_FONT_REGISTRY = "swt.fontRegistry";
112-
113-
@SuppressWarnings("removal")
114111
private static SWTFontRegistry newFontRegistry(Device device) {
115-
if ("legacy".equalsIgnoreCase(System.getProperty(SWT_FONT_REGISTRY)) && device instanceof Display display
116-
&& !display.isRescalingAtRuntime()) {
117-
return new LegacySWTFontRegistry(device);
112+
if (device instanceof Display display && display.isRescalingAtRuntime()) {
113+
return new ScalingSWTFontRegistry(device);
118114
}
119-
return new ScalingSWTFontRegistry(device);
120-
115+
return new DefaultSWTFontRegistry(device);
121116
}
122117
}

0 commit comments

Comments
 (0)