Top Description Fields Constructors Methods
org.controlsfx.glyphfont

public Class GlyphFont

extends Object
Class Inheritance
Known Direct Subclasses
org.controlsfx.glyphfont.FontAwesome
Imports
javafx.scene.text.Font, java.io.InputStream, java.util.HashMap, .Map

Represents a glyph font, which can be loaded locally or from a specified URL. Glyphs can be created easily using specified character defined in the font. For example, \uf013 in FontAwesome is used to represent a gear icon.

To simplify glyph customization, methods can be chained, for example:

 Glyph glyph = fontAwesome.create('\uf013').size(28).color(Color.RED); //GEAR
 

Here's a screenshot of two font packs being used to render images into JavaFX Button controls:

Screenshot of GlyphFont

Field Summary

Modifier and TypeField and Description
private final double
private boolean
private final Runnable
private final String
private final Map<String, Character>
namedGlyphs

* Private fields * *

Constructor Summary

AccessConstructor and Description
public
GlyphFont(String
glyph font name
fontName
,
int
default font size
defaultSize
,
final InputStream
input stream to load the font from
in
)

Loads glyph font from specified InputStream

public
GlyphFont(String
glyph font name
fontName
,
int
default font size
defaultSize
,
final String
A URL to load the font from
urlStr
)

Load glyph font from specified URL.

public
GlyphFont(String
glyph font name
fontName
,
int
default font size
defaultSize
,
final InputStream
input stream to load the font from
in
,
boolean
If true, the font will only be loaded when accessed
lazyLoad
)

Loads glyph font from specified InputStream

public
GlyphFont(String
glyph font name
fontName
,
int
default font size
defaultSize
,
final String
A URL to load the font from
urlStr
,
boolean
If true, the font will only be loaded when accessed
lazyLoad
)

Load glyph font from specified URL.

private
GlyphFont(String fontName, int defaultSize, Runnable fontLoader, boolean lazyLoad)

Creates a GlyphFont

Method Summary

Modifier and TypeMethod and Description
public Glyph

Returns:

instance of Glyph
create
(char
font character
character
)

Creates an instance of Glyph using specified font character

public Glyph

Returns:

glyph by its name or null if name is not found
create
(String
glyph name
glyphName
)

Creates an instance of Glyph using glyph name

public Glyph
create(Enum<?> glyph)

Creates an instance of Glyph using a known Glyph enum value

pack-priv synchronized void
ensureFontIsLoaded()

Ensures that the font is loaded

public Character
getCharacter(String glyphName)

Returns the character code which is mapped to this Name.

public double

Returns:

default font size
getDefaultSize
()

Returns the default font size

public String

Returns:

font name
getName
()

Returns font name

public void
register(String name, Character character)

Registers the given name-character mapping

public void
registerAll(Iterable<? extends INamedCharacter> namedCharacters)

Registers all given characters with their name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultSizeback to summary
private final double defaultSize
fontLoadedback to summary
private boolean fontLoaded
fontLoaderback to summary
private final Runnable fontLoader
fontNameback to summary
private final String fontName
namedGlyphsback to summary
private final Map<String, Character> namedGlyphs

* Private fields * *

Constructor Detail

GlyphFontback to summary
public GlyphFont(String fontName, int defaultSize, final InputStream in)

Loads glyph font from specified InputStream

Parameters
fontName:String

glyph font name

defaultSize:int

default font size

in:InputStream

input stream to load the font from

GlyphFontback to summary
public GlyphFont(String fontName, int defaultSize, final String urlStr)

Load glyph font from specified URL. Example for a local file: "file:///C:/Users/Bob/Fonts/icomoon.ttf" "file:///Users/Bob/Fonts/icomoon.ttf"

Parameters
fontName:String

glyph font name

defaultSize:int

default font size

urlStr:String

A URL to load the font from

GlyphFontback to summary
public GlyphFont(String fontName, int defaultSize, final InputStream in, boolean lazyLoad)

Loads glyph font from specified InputStream

Parameters
fontName:String

glyph font name

defaultSize:int

default font size

in:InputStream

input stream to load the font from

lazyLoad:boolean

If true, the font will only be loaded when accessed

GlyphFontback to summary
public GlyphFont(String fontName, int defaultSize, final String urlStr, boolean lazyLoad)

Load glyph font from specified URL. Example for a local file: "file:///C:/Users/Bob/Fonts/icomoon.ttf" "file:///Users/Bob/Fonts/icomoon.ttf"

Parameters
fontName:String

glyph font name

defaultSize:int

default font size

urlStr:String

A URL to load the font from

lazyLoad:boolean

If true, the font will only be loaded when accessed

GlyphFontback to summary
private GlyphFont(String fontName, int defaultSize, Runnable fontLoader, boolean lazyLoad)

Creates a GlyphFont

Method Detail

createback to summary
public Glyph create(char character)

Creates an instance of Glyph using specified font character

Parameters
character:char

font character

Returns:Glyph

instance of Glyph

createback to summary
public Glyph create(String glyphName)

Creates an instance of Glyph using glyph name

Parameters
glyphName:String

glyph name

Returns:Glyph

glyph by its name or null if name is not found

createback to summary
public Glyph create(Enum<?> glyph)

Creates an instance of Glyph using a known Glyph enum value

ensureFontIsLoadedback to summary
pack-priv synchronized void ensureFontIsLoaded()

Ensures that the font is loaded

getCharacterback to summary
public Character getCharacter(String glyphName)

Returns the character code which is mapped to this Name. If no match is found, NULL is returned.

getDefaultSizeback to summary
public double getDefaultSize()

Returns the default font size

Returns:double

default font size

getNameback to summary
public String getName()

Returns font name

Returns:String

font name

registerback to summary
public void register(String name, Character character)

Registers the given name-character mapping

registerAllback to summary
public void registerAll(Iterable<? extends INamedCharacter> namedCharacters)

Registers all given characters with their name.