Skip to content

Commit efb839a

Browse files
committed
[win32] fix endless loop with fixed text metrics
This commit fixes a regression that ignored bigger fixed font metrics in TextLayout in one scenario that led to an endloop recalculation loop. Fixes #1610
1 parent f8cbe80 commit efb839a

File tree

1 file changed

+7
-6
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+7
-6
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,8 +2137,9 @@ public FontMetrics getLineMetrics (int lineIndex) {
21372137
OS.DeleteDC(srcHdc);
21382138
device.internal_dispose_GC(hDC, null);
21392139

2140-
int ascentInPoints = this.ascent;
2141-
int descentInPoints = this.descent;
2140+
final int zoom = getZoom();
2141+
int ascentInPoints = Math.max(DPIUtil.scaleDown(getDevice(), lptm.tmAscent, zoom), this.ascent);
2142+
int descentInPoints = Math.max(DPIUtil.scaleDown(getDevice(), lptm.tmDescent, zoom), this.descent);
21422143
int leadingInPoints = DPIUtil.scaleDown(getDevice(), lptm.tmInternalLeading, availableFont.zoom);
21432144
if (text.length() != 0) {
21442145
for (StyleItem run : runs[lineIndex]) {
@@ -2149,10 +2150,10 @@ public FontMetrics getLineMetrics (int lineIndex) {
21492150
descentInPoints = Math.max(descentInPoints, run.descentInPoints);
21502151
}
21512152
}
2152-
lptm.tmAscent = DPIUtil.scaleUp(getDevice(), ascentInPoints, getZoom());
2153-
lptm.tmDescent = DPIUtil.scaleUp(getDevice(), descentInPoints, getZoom());
2154-
lptm.tmHeight = DPIUtil.scaleUp(getDevice(), ascentInPoints + descentInPoints, getZoom());
2155-
lptm.tmInternalLeading = DPIUtil.scaleUp(getDevice(), leadingInPoints, getZoom());
2153+
lptm.tmAscent = DPIUtil.scaleUp(getDevice(), ascentInPoints, zoom);
2154+
lptm.tmDescent = DPIUtil.scaleUp(getDevice(), descentInPoints, zoom);
2155+
lptm.tmHeight = DPIUtil.scaleUp(getDevice(), ascentInPoints + descentInPoints, zoom);
2156+
lptm.tmInternalLeading = DPIUtil.scaleUp(getDevice(), leadingInPoints, zoom);
21562157
lptm.tmAveCharWidth = 0;
21572158
return FontMetrics.win32_new(lptm, nativeZoom);
21582159
}

0 commit comments

Comments
 (0)