Skip to content

Conversation

@arunjose696
Copy link
Contributor

@arunjose696 arunjose696 commented Jun 6, 2025

Summary
This PR introduces the following changes:

1)Always use ScalingSWTFontRegistry
2)Rename DefaultSWTFontRegistry -> LegacySWTFontRegistry as this is not default anymore
3)Add a system property to use LegacySWTFontRegistry without monitor specific scaling active
4)Deprecate the LegacySWTFontRegistry(DefaultSWTFontRegistry)
5)additionally the change also makes sure all fonts are cached when they are created, this is necessary to make sure the systemfonts would also be cached when they are created (this change is to fix Test_org_eclipse_swt_graphics_GC.test_setFontLorg_eclipse_swt_graphics_Font which was broken with ScalingSwtFontRegistry)

Reproduction Steps
To use the legacy font registry instead of the default scaling registry, launch the application with the following system properties:

-Dswt.autoScale.updateOnRuntime=false
-Dswt.autoScale=false
-Dswt.fontRegistry=legacy

With these flags, the LegacySWTFontRegistry will be used.

If Dswt.fontRegistry is not set or Monitorscaling is enabled(current default behaviour) , SWT will default to using ScalingSWTFontRegistry.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2025

Test Results

   545 files  ±0     545 suites  ±0   31m 41s ⏱️ + 1m 9s
 4 403 tests +1   4 385 ✅ +1   18 💤 ±0  0 ❌ ±0 
16 733 runs  +1  16 593 ✅ +1  140 💤 ±0  0 ❌ ±0 

Results for commit 432847b. ± Comparison against base commit de1f3ef.

This pull request removes 6 and adds 7 tests. Note that renamed tests count towards both.
org.eclipse.swt.internal.DefaultSWTFontRegistryTests ‑ fontsAlwaysDependOnPrimaryZoom
org.eclipse.swt.internal.DefaultSWTFontRegistryTests ‑ fontsAreCached
org.eclipse.swt.internal.DefaultSWTFontRegistryTests ‑ systemFontsAlwaysDependOnPrimaryZoom
org.eclipse.swt.internal.DefaultSWTFontRegistryTests ‑ systemFontsAreCached
org.eclipse.swt.widgets.ControlWin32Tests ‑ testDoNotScaleFontCorrectlyInNoAutoScaleSzenario
org.eclipse.swt.widgets.ControlWin32Tests ‑ testScaleFontCorrectlyInAutoScaleSzenario
org.eclipse.swt.internal.LegacySWTFontRegistryTests ‑ fontsAlwaysDependOnPrimaryZoom
org.eclipse.swt.internal.LegacySWTFontRegistryTests ‑ fontsAreCached
org.eclipse.swt.internal.LegacySWTFontRegistryTests ‑ systemFontsAlwaysDependOnPrimaryZoom
org.eclipse.swt.internal.LegacySWTFontRegistryTests ‑ systemFontsAreCached
org.eclipse.swt.widgets.ControlWin32Tests ‑ testDoNotScaleFontInNoAutoScaleScenarioWithLegacyFontRegistry
org.eclipse.swt.widgets.ControlWin32Tests ‑ testScaleFontCorrectlyInAutoScaleScenario
org.eclipse.swt.widgets.ControlWin32Tests ‑ testScaleFontCorrectlyInNoAutoScaleScenario

♻️ This comment has been updated with latest results.

@arunjose696 arunjose696 force-pushed the arunjose696/312 branch 2 times, most recently from 3241eaf to aeccc6c Compare June 6, 2025 12:54
@arunjose696 arunjose696 marked this pull request as draft June 6, 2025 12:56
@arunjose696 arunjose696 force-pushed the arunjose696/312 branch 10 times, most recently from c3ea0da to 1553d4d Compare June 12, 2025 08:28
private Font createAndCacheFont(int zoom) {
Font newFont = createFont(zoom);
customFontHandlesKeyMap.put(Font.win32_getHandle(newFont), this);
FontData clonedFontData = new FontData(newFont.getFontData()[0].toString());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloning FontData should be replaced with new constructors if #2128 gets merged

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is actually a fix for an issue independent of the refactoring. I would extract that one out + a separate test the checks that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised a new PR for this #2237 , Not removing the changes in this PR as the CI runs would fail for this

@arunjose696 arunjose696 marked this pull request as ready for review June 12, 2025 08:39
private Font createAndCacheFont(int zoom) {
Font newFont = createFont(zoom);
customFontHandlesKeyMap.put(Font.win32_getHandle(newFont), this);
FontData clonedFontData = new FontData(newFont.getFontData()[0].toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is actually a fix for an issue independent of the refactoring. I would extract that one out + a separate test the checks that

@arunjose696 arunjose696 force-pushed the arunjose696/312 branch 3 times, most recently from 7e3ee0c to 99b63f0 Compare June 17, 2025 11:59
Copy link
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments

fedejeanne
fedejeanne previously approved these changes Jun 23, 2025
Copy link
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arunjose696 please add the necessary @SuppressWarnings("removal") so that the checks do not fail

@fedejeanne fedejeanne dismissed their stale review June 23, 2025 14:06

@SuppressWarnings("removal") missing.

    1)Always use ScalingSWTFontRegistry
    2)Rename DefaultSWTFontRegistry -> LegacySWTFontRegistry as this is not default anymore
    3)Add a system property to use LegacySWTFontRegistry without monitor specific scaling active
    4)Deprecate the LegacySWTFontRegistry(DefaultSWTFontRegistry)
@arunjose696
Copy link
Contributor Author

@arunjose696 please add the necessary @SuppressWarnings("removal") so that the checks do not fail

Have added SuppressWarnings, to usages of deprecated class(LegacySWTFontRegistry), still see the warnings, @fedejeanne is it required to add annotations elsewhere?

@fedejeanne
Copy link
Member

Yes, you missed one spot: bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/LegacySWTFontRegistryTests.java

You can find the new warnings when clicking in the failing check:

image

Then look for the new issues (they are at the top of the list):

image

Copy link
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected, the failures are unrelated and you already added the necessary @SuppressWarnings

@fedejeanne fedejeanne merged commit a413b4b into eclipse-platform:master Jun 24, 2025
12 of 17 checks passed
@fedejeanne fedejeanne deleted the arunjose696/312 branch June 24, 2025 09:12
@akurtakov
Copy link
Member

@arunjose696
Copy link
Contributor Author

This has caused warnings in I-build e.g. https://download.eclipse.org/eclipse/downloads/drops4/I20250625-0320/compilelogs/plugins/org.eclipse.swt.win32.win32.aarch64_3.131.0.v20250624-0912/test.html

This seems to be a false positive, have added necessary @SuppressWarnings for this function, dont see any warnings appearing in IDE as well.

@fedejeanne
Copy link
Member

It just occurs to me: could it be that the check is complaining about the deprecation without removal?

The IDE is smart enough to know that suppressing the "removal" notices also suppresses the "deprecation" notices, but I don't know about the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completely switch to ScalingSWTFontRegistry

4 participants