Skip to content
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

Add test for StyledText with fixed font metrics #1689

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -5934,4 +5936,22 @@ 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);
font.dispose();
gc.dispose();
}
}
Loading