Package org.eclipse.e4.ui.css.swt.helpers

# Class CSSSWTFontHelper

java.lang.Object
org.eclipse.e4.ui.css.swt.helpers.CSSSWTFontHelper

public class CSSSWTFontHelper extends Object
CSS SWT Font Helper to :

- get CSS2FontProperties from Font of SWT Control.
- get Font of SWT Control from CSS2FontProperties.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`FONT_DEFINITION_MARKER`

## Constructor Summary

Constructors
Constructor
Description
`CSSSWTFontHelper()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`equals(Font f1, Font f2)`
On certain platforms, may have two font instances that actually are the same
`static CSS2FontProperties`
`getCSS2FontProperties(Font font)`
Build CSS2FontProperties from SWT Font.
`static CSS2FontProperties`
`getCSS2FontProperties(Font font, CSSElementContext context)`
`static CSS2FontProperties`
`getCSS2FontProperties(Widget widget, CSSElementContext context)`
Get CSS2FontProperties from the widget.
`static CSS2FontProperties`
`getCSS2FontProperties(Widget widget, Font font, CSSElementContext context)`
Get CSS2FontProperties from Control stored into Data of Control.
`static FontData`
`getFirstFontData(Font font)`
Return first FontData from SWT Font.
`static FontData`
`getFirstFontData(Control control)`
Return first FontData from Control Font.
`static Font`
`getFont(CSS2FontProperties fontProperties, FontData oldFontData, Display display)`
`static Font`
`getFont(CSS2FontProperties fontProperties, Control control)`
Get CSS2FontProperties from Font of JComponent and store CSS2FontProperties instance into ClientProperty of JComponent.
`static String`
`getFontComposite(Font font)`
Return CSS Value font-family from SWT Font
`static String`
`getFontComposite(FontData fontData)`
`static String`
`getFontComposite(Control control)`
Return CSS Value font-family from Control Font
`static FontData`
`getFontData(CSS2FontProperties fontProperties, FontData oldFontData)`
Return FontData from `CSS2FontProperties`.
`static String`
`getFontFamily(Font font)`
Return CSS Value font-family from SWT Font
`static String`
`getFontFamily(FontData fontData)`
`static String`
`getFontFamily(Widget widget)`
Return CSS Value font-family from the widget's font, if it has a font
`static String`
`getFontSize(Font font)`
Return CSS Value font-size from SWT Font
`static String`
`getFontSize(FontData fontData)`
`static String`
`getFontSize(Widget widget)`
Return CSS Value font-size the widget's font, if it has a font
`static String`
`getFontStyle(Font font)`
Return CSS Value font-style from SWT Font
`static String`
`getFontStyle(FontData fontData)`
`static String`
`getFontStyle(Widget widget)`
Return CSS Value font-style from the widget's font, if it has a font
`static String`
`getFontWeight(Font font)`
Return CSS Value font-weight from Control Font
`static String`
`getFontWeight(FontData fontData)`
`static String`
`getFontWeight(Widget widget)`
Return CSS Value font-weight from the widget's font, if it has a font
`static int`
`getSWTStyle(CSS2FontProperties fontProperties, FontData fontData)`
Return SWT style Font from `CSS2FontProperties`.
`static boolean`
`hasFontDefinitionAsFamily(CSSValue value)`
`static boolean`
`isBold(FontData fontData)`
`static boolean`
`isItalic(FontData fontData)`
`static void`
`restoreDefaultFont(CTabItem item)`
`static void`
`restoreDefaultFont(Control control)`
`static void`
`setFont(CTabItem item, Font font)`
Helper function to avoid setting fonts unnecessarily
`static void`
`setFont(Control control, Font font)`
Helper function to avoid setting fonts unnecessarily
`static void`
`storeDefaultFont(CTabItem item)`
`static void`
`storeDefaultFont(Control control)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### FONT_DEFINITION_MARKER

public static final String FONT_DEFINITION_MARKER

See Also:
  - Constant Field Values

## Constructor Details

### CSSSWTFontHelper

public CSSSWTFontHelper()

## Method Details

### getCSS2FontProperties

public static CSS2FontProperties getCSS2FontProperties(Widget widget, Font font, CSSElementContext context)
Get CSS2FontProperties from Control stored into Data of Control. If CSS2FontProperties doesn't exist, create it from Font of Control and store it into Data of Control.

### getCSS2FontProperties

public static CSS2FontProperties getCSS2FontProperties(Widget widget, CSSElementContext context)
Get CSS2FontProperties from the widget. If CSS2FontProperties doesn't exist, create it from the widget's font, if it has one, and then store it in the widget's data if applicable.

Parameters:
  `widget` - the widget to retrieve CSS2 font properties from
Returns:
  the font properties of the specified widget, or `null` if none

### getCSS2FontProperties

public static CSS2FontProperties getCSS2FontProperties(Font font, CSSElementContext context)

### getCSS2FontProperties

public static CSS2FontProperties getCSS2FontProperties(Font font)
Build CSS2FontProperties from SWT Font.

### getFont

public static Font getFont(CSS2FontProperties fontProperties, Control control)
Get CSS2FontProperties from Font of JComponent and store CSS2FontProperties instance into ClientProperty of JComponent.

### getFont

public static Font getFont(CSS2FontProperties fontProperties, FontData oldFontData, Display display)

### getFontData

public static FontData getFontData(CSS2FontProperties fontProperties, FontData oldFontData)
Return FontData from `CSS2FontProperties`.

### hasFontDefinitionAsFamily

public static boolean hasFontDefinitionAsFamily(CSSValue value)

### getSWTStyle

public static int getSWTStyle(CSS2FontProperties fontProperties, FontData fontData)
Return SWT style Font from `CSS2FontProperties`.

### getFontFamily

public static String getFontFamily(Widget widget)
Return CSS Value font-family from the widget's font, if it has a font

### getFontFamily

public static String getFontFamily(Font font)
Return CSS Value font-family from SWT Font

### getFontFamily

public static String getFontFamily(FontData fontData)

### getFontSize

public static String getFontSize(Widget widget)
Return CSS Value font-size the widget's font, if it has a font

### getFontSize

public static String getFontSize(Font font)
Return CSS Value font-size from SWT Font

### getFontSize

public static String getFontSize(FontData fontData)

### getFontStyle

public static String getFontStyle(Widget widget)
Return CSS Value font-style from the widget's font, if it has a font

### getFontStyle

public static String getFontStyle(Font font)
Return CSS Value font-style from SWT Font

### getFontStyle

public static String getFontStyle(FontData fontData)

### isItalic

public static boolean isItalic(FontData fontData)

### getFontWeight

public static String getFontWeight(Widget widget)
Return CSS Value font-weight from the widget's font, if it has a font

### getFontWeight

public static String getFontWeight(Font font)
Return CSS Value font-weight from Control Font

### getFontWeight

public static String getFontWeight(FontData fontData)

### isBold

public static boolean isBold(FontData fontData)

### getFontComposite

public static String getFontComposite(Control control)
Return CSS Value font-family from Control Font

### getFontComposite

public static String getFontComposite(Font font)
Return CSS Value font-family from SWT Font

### getFontComposite

public static String getFontComposite(FontData fontData)

### getFirstFontData

public static FontData getFirstFontData(Control control)
Return first FontData from Control Font.

### getFirstFontData

public static FontData getFirstFontData(Font font)
Return first FontData from SWT Font.

### storeDefaultFont

public static void storeDefaultFont(Control control)

### storeDefaultFont

public static void storeDefaultFont(CTabItem item)

### restoreDefaultFont

public static void restoreDefaultFont(Control control)

### restoreDefaultFont

public static void restoreDefaultFont(CTabItem item)

### setFont

public static void setFont(Control control, Font font)
Helper function to avoid setting fonts unnecessarily

### setFont

public static void setFont(CTabItem item, Font font)
Helper function to avoid setting fonts unnecessarily

### equals

public static boolean equals(Font f1, Font f2)
On certain platforms, may have two font instances that actually are the same