Skip to content

Commit 055ec84

Browse files
akoch-yattafedejeanne
authored andcommitted
[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 b35fc01 commit 055ec84

File tree

1 file changed

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

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,10 +2136,10 @@ public FontMetrics getLineMetrics (int lineIndex) {
21362136
metricsAdapter.GetTextMetrics(srcHdc, lptm);
21372137
OS.DeleteDC(srcHdc);
21382138
device.internal_dispose_GC(hDC, null);
2139-
2140-
int ascentInPoints = this.ascent;
2141-
int descentInPoints = this.descent;
2142-
int leadingInPoints = DPIUtil.scaleDown(getDevice(), lptm.tmInternalLeading, availableFont.zoom);
2139+
final int zoom = getZoom();
2140+
int ascentInPoints = Math.max(DPIUtil.scaleDown(this.device, lptm.tmAscent, zoom), this.ascent);
2141+
int descentInPoints = Math.max(DPIUtil.scaleDown(this.device, lptm.tmDescent, zoom), this.descent);
2142+
int leadingInPoints = DPIUtil.scaleDown(this.device, lptm.tmInternalLeading, availableFont.zoom);
21432143
if (text.length() != 0) {
21442144
for (StyleItem run : runs[lineIndex]) {
21452145
if (run.ascentInPoints > ascentInPoints) {
@@ -2149,10 +2149,10 @@ public FontMetrics getLineMetrics (int lineIndex) {
21492149
descentInPoints = Math.max(descentInPoints, run.descentInPoints);
21502150
}
21512151
}
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());
2152+
lptm.tmAscent = DPIUtil.scaleUp(this.device, ascentInPoints, zoom);
2153+
lptm.tmDescent = DPIUtil.scaleUp(this.device, descentInPoints, zoom);
2154+
lptm.tmHeight = DPIUtil.scaleUp(this.device, ascentInPoints + descentInPoints, zoom);
2155+
lptm.tmInternalLeading = DPIUtil.scaleUp(this.device, leadingInPoints, zoom);
21562156
lptm.tmAveCharWidth = 0;
21572157
return FontMetrics.win32_new(lptm, nativeZoom);
21582158
}

0 commit comments

Comments
 (0)