Scaling of FontDialog breaks during dpi change. In this screenshot, it is 100 -> 150
Test Example:
public class FontDialogExample {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("FontDialog Example");
shell.setSize(300, 200);
// Label to display the selected font
Label label = new Label(shell, SWT.NONE);
label.setText("Sample Text");
label.setBounds(50, 50, 200, 50);
// Button to open the FontDialog
Button fontButton = new Button(shell, SWT.PUSH);
fontButton.setText("Choose Font");
fontButton.setBounds(50, 120, 100, 30);
fontButton.addListener(SWT.Selection, event -> {
FontDialog fontDialog = new FontDialog(shell);
fontDialog.setText("Select Font");
// Set default font selection
FontData initialFont = label.getFont().getFontData()[0];
fontDialog.setFontList(new FontData[] { initialFont });
// Open the dialog and get the selected font data
FontData selectedFont = fontDialog.open();
if (selectedFont != null) {
// Apply the selected font to the label
Font font = new Font(display, selectedFont);
label.setFont(font);
// Dispose of the font when no longer needed
shell.addListener(SWT.Dispose, e -> font.dispose());
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Scaling of FontDialog breaks during dpi change. In this screenshot, it is 100 -> 150
Test Example:
Run the example with the following VM Arguments