Skip to content

Conversation

wahlbrink
Copy link
Contributor

Fixes: #2461

Copy link
Contributor

github-actions bot commented Sep 10, 2025

Test Results

   546 files  ±0     546 suites  ±0   33m 46s ⏱️ - 3m 26s
 4 431 tests ±0   4 414 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 764 runs  ±0  16 637 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 5da0ca1. ± Comparison against base commit c6a29a9.

♻️ This comment has been updated with latest results.

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 proposal! Since FontMetrics is a kind of central class (thus adapting it is critical) some more information about potential impacts (such as on the various consumers in the Eclipse Platform) and how far they were or need to be tested would be good. Also some information on how to test and reproduce changes in behavior would be nice.

@ptziegler fyi, as Draw2d's TextUtilities make use of this method

@@ -108,7 +108,7 @@ public int getAscent() {
* @since 3.107
*/
public double getAverageCharacterWidth() {
return getAverageCharWidth();
return DPIUtil.pixelToPoint((float)handle.tmAveCharWidth, getZoom());
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add a method converting doubles instead of trimming to float and then converting back?

The value for getAverageCharacterWidth was rounded, even though its
method signature returns a double. The unrounded value provides a better
estimation of the average character width for non-integer zoom factors.

Fixes: eclipse-platform#2461
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.

[Win32] FontMetrics.getAverageCharacterWidth should return unrounded value
2 participants