Java Code Examples for org.eclipse.swt.widgets.Control#getFont()

The following examples show how to use org.eclipse.swt.widgets.Control#getFont() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 2
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});

}
 
Example 3
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 4
Source Project: nebula   File: SWTGraphicUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Build a font from a given control. Useful if we just want a bold label for
 * example
 *
 * @param control control that handle the default font
 * @param style new style
 * @return a font with the given style
 */
public static Font buildFontFrom(final Control control, final int style) {
	final Font temp = control.getFont();
	final FontData[] fontData = temp.getFontData();
	if (fontData == null || fontData.length == 0) {
		return temp;
	}
	return new Font(control.getDisplay(), fontData[0].getName(), fontData[0].getHeight(), style);
}
 
Example 5
Source Project: nebula   File: SWTGraphicUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Build a font from a given control. Useful if we just want a bold label for
 * example
 *
 * @param control control that handle the default font
 * @param style new style
 * @return a font with the given style
 */
public static Font buildFontFrom(final Control control, final int style, final int size) {
	final Font temp = control.getFont();
	final FontData[] fontData = temp.getFontData();
	if (fontData == null || fontData.length == 0) {
		return temp;
	}
	return new Font(control.getDisplay(), fontData[0].getName(), size, style);
}
 
Example 6
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});
}
 
Example 7
Source Project: nebula   File: CSSEngineHelper.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 8
Source Project: xds-ide   File: SwtUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static Font modifyFont(Control c, int flags) {
	Font f = c.getFont();
	String fontName = f.getFontData()[0].getName();
	int fontSize = f.getFontData()[0].getHeight();
	int fontStyle = f.getFontData()[0].getStyle() | flags;
	return new Font(c.getDisplay(), new FontData(fontName, fontSize,
			fontStyle));
}
 
Example 9
public PixelConverter(Control control) {
	this(control.getFont());
}
 
Example 10
Source Project: xds-ide   File: UiUtils.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public static Font modifyFont(Control c, int flags) {
  Font f = c.getFont();
  return modifyFont(c.getDisplay(), f, flags);
}
 
Example 11
public PixelConverter(Control control) {
	this(control.getFont());
}
 
Example 12
Source Project: birt   File: PixelConverter.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public PixelConverter( Control control )
{
	this( control.getFont( ) );
}
 
Example 13
Source Project: arx   File: DataTableFillLayoutStyle.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 
 *
 * @param control
 */
public DataTableFillLayoutStyle(Control control) {
    font = control.getFont();
}
 
Example 14
Source Project: arx   File: CTConfiguration.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new grid or table.
 * @param parent
 * @param style
 */
public CTConfiguration(Control parent, int style){
    this.font = parent.getFont();
    this.style = style;
}