Skip to content

Commit a6520d0

Browse files
committed
[Win32] Consider SWT.DRAW_DELIMITER flag when drawing text with GDI+
The GC.drawText() implementation falls back to using GDI instead of GDI+ (even if enabled) in many cases for historic reasons. There were issues with rendering tabs back then. One of the few cases where GDI+ is used is when glyphs that are non existing for GDI are used. In that case, however, the DRAW_DELIMITER flag is not properly considered. The behavior is always as if the flag was enabled, i.e., line delimiters is always drawn even if the flag is not set. This change corrects the behavior of the GDI+ text drawing implementation to consider if the DRAW_DELIMITER flag is not set. In consequence, strings with glyphs that are not supported by GDI are now rendered without line breaks if undesired as per defined flags. Contributes to #3091
1 parent 716e80e commit a6520d0

File tree

1 file changed

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

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,9 @@ private RectF drawText(long gdipGraphics, char[] buffer, int start, int length,
30373037
private void drawTextGDIP(long gdipGraphics, String string, int x, int y, int flags, boolean draw, Point size) {
30383038
boolean needsBounds = !draw || (flags & SWT.DRAW_TRANSPARENT) == 0;
30393039
char[] buffer;
3040+
if ((flags & SWT.DRAW_DELIMITER) == 0) {
3041+
string = string.replace("\r\n", "").replace("\r", "").replace("\n", "");
3042+
}
30403043
int length = string.length();
30413044
if (length != 0) {
30423045
buffer = string.toCharArray();

0 commit comments

Comments
 (0)