public class FontAwesome extends GlyphFont
GlyphFont for the FontAwesome font set (see
the FontAwesome website
for more details). Note that at present the FontAwesome font is not distributed
with ControlsFX, and is instead loaded from Bootstrap CDN at runtime.
To use FontAwesome (or indeed any glyph font) in your JavaFX application, you firstly have to get access to the FontAwesome glyph font. You do this by doing the following:
GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
This code works because all glyph fonts are found dynamically at runtime
by the GlyphFontRegistry class, so you can simply request the font
set you want from there.
Once the font set has been loaded, you can simply start creating
FontAwesome.Glyph nodes and place them in your user interface. For example:
new Button("", fontAwesome.fontColor(Color.RED).create(\uf013));
Of course, this requires you to know that \uf013 maps to
a 'gear' icon, which is not always intuitive (especially when you re-read the
code in the future). A simpler approach is to do the following:
new Button("", FontAwesome.Glyph.GEAR.create());
It is possible to achieve the same result without creating a reference to icon font by simply using
GlyphFontRegistry methods
new Button("", GlyphFontRegistry.glyph("FontAwesome|GEAR");GlyphFont,
GlyphFontRegistry,
FontAwesome.Glyph| Modifier and Type | Class and Description |
|---|---|
static class |
FontAwesome.Glyph
The individual glyphs offered by the FontAwesome font.
|
| Constructor and Description |
|---|
FontAwesome()
Do not call this constructor directly - instead access the
FontAwesome.Glyph public static enumeration (and call the
FontAwesome.Glyph.create() method to create the glyph nodes), or
use the GlyphFontRegistry class to get access. |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Character> |
getGlyphs()
Returns glyph dictionary
|
public FontAwesome()
FontAwesome.Glyph public static enumeration (and call the
FontAwesome.Glyph.create() method to create the glyph nodes), or
use the GlyphFontRegistry class to get access.