Skip to content

Make fonts use autoscaled zoom when swt.autoScale is fixed #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

arunjose696
Copy link
Contributor

@arunjose696 arunjose696 commented Aug 5, 2025

This change ensures that images and fonts share the same zoom level when a fixed autoscale value is used.

Previously, when different GCs were created for images and widgets, their native zoom(GC.data.nativeZoom) levels could differ, causing inconsistencies.

For example, in LineNumberRuler, one GC is created from an image (used for rendering), and another is created from a widget (used for text measurement). The differing native zoom levels between these GCs led to incorrect text width calculations. Specifically, one GC was used to measure the text extent, while the other used those measurements to calculate the width of the columns where the text would be drawn and this resulted in #2311

Steps to reproduce

1)Checkout the first commit. Run steps in #2306
2)Checkout the second commit, this solves the issue with lineNumberRuler

First commit which reverts changes from #2306 Fixes #2361
Second commit fixes the original issue in #2311

Copy link
Contributor

github-actions bot commented Aug 5, 2025

Test Results

   546 files  ±0     546 suites  ±0   30m 55s ⏱️ + 1m 30s
 4 425 tests ±0   4 408 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 746 runs  ±0  16 619 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 518533c. ± Comparison against base commit 9eea8f6.

♻️ This comment has been updated with latest results.

@arunjose696 arunjose696 marked this pull request as ready for review August 5, 2025 12:34
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

The changes look sound to me. I have some proposals and implicit questions whether I understood everything correctly.

Comment on lines 773 to 775
return DPIUtil.getNativeZoomForAutoscaleProperty(gc.data.nativeZoom);
}
return nativeZoom;
return DPIUtil.getNativeZoomForAutoscaleProperty(nativeZoom);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is really the right place/change to TextLayout. We should clarify what the field nativeZoom in TextLayout is supposed to be: is it really a nativeZoom (such as the native zoom of a GC of a StyledText) or it is rather a fontZoom? If it was really a nativeZoom, I would find the change weird because computeRuns calls this method to set the nativeZoom field, which would make it effectively some fontZoom. When I take a look at the usages of nativeZoom, it seems to rather be a fontZoom. Then, however, calling DPIUtil.getNativeZoomForAutoscaleProperty(nativeZoom) would not really make sense here, as nativeZoom already is such an adapted value.
In my understanding nativeZoom should be renamed to fontZoom and then only the change to the first return statement should be applied.

this really the right place for the adaptation in TextLayout()? I see three callers of this method:

  • computeRuns() calls it to set a new nativeZoom: shouldn't that native zoom

Copy link
Contributor Author

@arunjose696 arunjose696 Aug 5, 2025

Choose a reason for hiding this comment

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

Since the native zoom is set based on a font when a font is applied to a TextLayout, it makes sense to rename nativeZoom to fontZoom.

I reviewed all usages of the variable. There is a minor ambiguity in the getZoom() method, where nativeZoom(now fontZoom) used. This method is called for line and offset operations, which I am slightly not sure if it is directly tied to font . However, since line height and offsets are also influenced by the font zoom, I believe the renaming still makes sense.

@arunjose696 arunjose696 force-pushed the arunjose696/383/FixedNativeZoom branch 2 times, most recently from 1799f06 to 057a824 Compare August 5, 2025 17:33
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

Thank you for the update, looks even cleaner now!

I have only minor comments/proposals left and one question regarding the initialization of the fontZoom (former nativeZoom) in TextLayout.

@arunjose696 arunjose696 force-pushed the arunjose696/383/FixedNativeZoom branch 3 times, most recently from a21a988 to d0abdb3 Compare August 6, 2025 14:42
@arunjose696 arunjose696 changed the title Modify gc.data.nativeDeviceZoom to use autoscaled zoom when swt.autoScale is fixed Make fonts use autoscaled zoom when swt.autoScale is fixed Aug 7, 2025
@HeikoKlare
Copy link
Contributor

The change now looks fine to me. It just has conflicts now because we meanwhile merged #2376.
Could you adapt this PR, @arunjose696?

@arunjose696 arunjose696 force-pushed the arunjose696/383/FixedNativeZoom branch from d0abdb3 to f34f607 Compare August 7, 2025 16:18
swt.autoScale is fixed

This change ensures that images and fonts share the same zoom level when
a fixed autoscale value is used.

Previously, when different GCs were created for images and widgets,
their native zoom levels could differ, causing inconsistencies.
For example, in LineNumberRuler, one GC is created from an image and
another from a widget for text measurement. The differing native zooms
led to incorrect text width calculations when applied across GCs.

This update aligns fontZoom to the autoscaled zoom value when autoScale
value is fixed
Fixes eclipse-platform#2311
@arunjose696 arunjose696 force-pushed the arunjose696/383/FixedNativeZoom branch from f34f607 to 518533c Compare August 7, 2025 16:35
@arunjose696
Copy link
Contributor Author

arunjose696 commented Aug 7, 2025

The change now looks fine to me. It just has conflicts now because we meanwhile merged #2376. Could you adapt this PR, @arunjose696?

done

@HeikoKlare
Copy link
Contributor

@arunjose696 since we found that this PR was created under a wrong assumption (fonts to be scaled according to autoscale zoom instead of native zoom when using a fixed autoscale value), I think unfortunately this PR cannot be merged/adapted in a reasonable way. Can we close it or do you see anything of value in it that we should extract into another PR?

@arunjose696
Copy link
Contributor Author

Closing this PR

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.

Wrong text extent calculation with swt.autoScale=int200 [Win32] Wrong text extent calculation with swt.autoScale=int200
3 participants