diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java index e460ab4a619..bedae42bd70 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java @@ -63,6 +63,8 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GlyphMetrics; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; @@ -5934,4 +5936,20 @@ public void test_rangeSelectionKeepsCaret() { assertEquals("Selection does not start from caret", initialOffset, text.getSelection().x); assertNotEquals("Selection is not left-to-right", text.getSelection().x, text.getCaretOffset()); } + +@Test +public void test_bug1610_fixedLineHeightWithChangingToSmallerFont_noException() { + shell.setVisible(true); + shell.setLayout(new GridLayout(1, false)); + + GC gc = new GC(shell.getDisplay()); + FontMetrics metrics = gc.getFontMetrics(); + text.setFixedLineMetrics(metrics); + + FontData fontData = text.getFont().getFontData()[0]; + text.setText(""); + int smallFontHeight = metrics.getAscent() + metrics.getDescent() - 4; + Font font = new Font(text.getDisplay(), fontData.getName(), smallFontHeight, fontData.getStyle()); + text.setFont(font); +} }