how to get current font used for treeviewer? [message #491817] |
Fri, 16 October 2009 00:08 |
Natasha D'Silva Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi,
I have a TreeViewer, and based on certain conditions, I would like its label provider to return a bold font for some elements.
What is the proper way to do this?
How do I know what the current font is for the view?
If the user changes the default settings and makes their font larger or smaller, I would prefer if my code was oblivious to that, and the code below is not.
My label provier implements ITableFontProvider, and right now, this is what I have:
public Font getFont(Object element, int columnIndex) {
if(condition) {
FontData fontData = Display.getCurrent().getSystemFont()
.getFontData()[0];
String name = fontData.getName();
return JFaceResources.getFontRegistry().getBold(name);
}
}
return null;
}
Right now, the above code appears to work, but if I change my wnidows color scheme to use larger fonts, the font returned by Display.getCurrent().getSystemFont()
.getFontData()[0]; is different and smaller.
If I do not supply a bolded font for an element, its font is in sync with the system font, so how do I get the current font, and make it bold?
Thanks.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03815 seconds