Skip to content
Merged
Show file tree
Hide file tree
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 @@ -3037,6 +3037,9 @@ private RectF drawText(long gdipGraphics, char[] buffer, int start, int length,
private void drawTextGDIP(long gdipGraphics, String string, int x, int y, int flags, boolean draw, Point size) {
boolean needsBounds = !draw || (flags & SWT.DRAW_TRANSPARENT) == 0;
char[] buffer;
if ((flags & SWT.DRAW_DELIMITER) == 0) {
string = string.replaceAll("[\\r\\n]+", "");
}
int length = string.length();
if (length != 0) {
buffer = string.toCharArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,18 @@ public void test_textExtentLjava_lang_StringI() {
assertEquals(SWT.ERROR_GRAPHIC_DISPOSED, e.code);
}

@Test
public void test_textExtentLjava_lang_StringI_disabledLineDelimiter() {
gc.setAdvanced(false);
Point ptWithoutAdvanced = gc.textExtent("abc\u4E2D" + System.lineSeparator() + "def", 0);
gc.setAdvanced(true);
Point ptWithAdvanced = gc.textExtent("abc\u4E2D" + System.lineSeparator() + "def", 0);
// Due to slightly different rendering, size must not be identical but similar in advanced/non-advanced mode
assertTrue(Math.abs(ptWithAdvanced.x - ptWithoutAdvanced.x) <= 2);
assertTrue(Math.abs(ptWithAdvanced.y - ptWithoutAdvanced.y) <= 2);
gc.dispose();
}

@Test
public void test_toString() {
String s = gc.toString();
Expand Down
Loading