-
Notifications
You must be signed in to change notification settings - Fork 191
Open
Description
Windows 11
Java 21
Latest SWT from I-builds
This is moved from eclipse-gef/gef-classic#1023
If a Font is used to draw text in a GC that has either Underline or Strikeout the text is not rendered if GC.setAdvanced(true)
The Underline or Strikeout for a Font can be set using a FontDialog:
Run the Snippet:
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FontTest {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setSize(200, 150);
// Rather than open a FontDialog we'll create the Font from an equivalent FontData string which has underline set
String fontString = "1|Arial|10.125|0|WINDOWS|1|-27|0|0|0|400|0|1|0|0|3|2|1|34|Arial";
FontData fd = new FontData(fontString);
Font font = new Font(display, fd);
shell.addPaintListener(e -> {
GC gc = e.gc;
gc.setFont(font);
gc.drawText("Hello World", 10, 10);
gc.setAdvanced(true); // Comment this out to render text
gc.drawText("Hello World", 10, 50);
});
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) {
display.sleep();
}
}
}
}It should look like this:
But looks like this:

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels