Change just the font size in SWT

I need to use a larger font for one of the labels.

label.setFont( new Font(display,"Arial", 14, SWT.BOLD ) );

but obviously Arial is not always the default font. I want to change just the size and keep everything else at default values.

Can I do something like

label.setFontSize( 14 );

to avoid setting the other parameters? Or can I at least find out the name of the font that is actually being used as default?


I believe you could do something like

FontData[] fD = label.getFont().getFontData();
label.setFont( new Font(display,fD[0]));

As long as no more than one font is returned, that should work.

You can do the following:

FontData[] fontData = label.getFont().getFontData();
for(int i = 0; i < fontData.length; ++i)

final Font newFont = new Font(display, fontData);

// Since you created the font, you must dispose it
label.addDisposeListener(new DisposeListener() {
    public void widgetDisposed(DisposeEvent e) {

Need Your Help

using array_search for multi dimensional array

php arrays multidimensional-array

using array_search in a 1 dimensional array is simple

Find the most frequent number in a numpy vector

python numpy statistics

Suppose I have the following list in python: