- java.lang.Object
-
- org.controlsfx.glyphfont.GlyphFont
-
- Direct Known Subclasses:
FontAwesome
public class GlyphFont extends Object
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); //GEARHere's a screenshot of two font packs being used to render images into JavaFX Button controls:

-
-
Constructor Summary
Constructors Constructor Description GlyphFont(String fontName, int defaultSize, InputStream in)Loads glyph font from specifiedInputStreamGlyphFont(String fontName, int defaultSize, InputStream in, boolean lazyLoad)Loads glyph font from specifiedInputStreamGlyphFont(String fontName, int defaultSize, String urlStr)Load glyph font from specified URL.GlyphFont(String fontName, int defaultSize, String urlStr, boolean lazyLoad)Load glyph font from specified URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Glyphcreate(char character)Creates an instance ofGlyphusing specified font characterGlyphcreate(Enum<?> glyph)Creates an instance ofGlyphusing a known Glyph enum valueGlyphcreate(String glyphName)Creates an instance ofGlyphusing glyph nameCharactergetCharacter(String glyphName)Returns the character code which is mapped to this Name.doublegetDefaultSize()Returns the default font sizeStringgetName()Returns font namevoidregister(String name, Character character)Registers the given name-character mappingvoidregisterAll(Iterable<? extends INamedCharacter> namedCharacters)Registers all given characters with their name.
-
-
-
Constructor Detail
-
GlyphFont
public GlyphFont(String fontName, int defaultSize, InputStream in)
Loads glyph font from specifiedInputStream- Parameters:
fontName- glyph font namedefaultSize- default font sizein- input stream to load the font from
-
GlyphFont
public GlyphFont(String fontName, int defaultSize, 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- glyph font namedefaultSize- default font sizeurlStr- A URL to load the font from
-
GlyphFont
public GlyphFont(String fontName, int defaultSize, InputStream in, boolean lazyLoad)
Loads glyph font from specifiedInputStream- Parameters:
fontName- glyph font namedefaultSize- default font sizein- input stream to load the font fromlazyLoad- If true, the font will only be loaded when accessed
-
GlyphFont
public GlyphFont(String fontName, int defaultSize, 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- glyph font namedefaultSize- default font sizeurlStr- A URL to load the font fromlazyLoad- If true, the font will only be loaded when accessed
-
-
Method Detail
-
getName
public String getName()
Returns font name- Returns:
- font name
-
getDefaultSize
public double getDefaultSize()
Returns the default font size- Returns:
- default font size
-
create
public Glyph create(char character)
Creates an instance ofGlyphusing specified font character- Parameters:
character- font character- Returns:
- instance of
Glyph
-
create
public Glyph create(String glyphName)
Creates an instance ofGlyphusing glyph name- Parameters:
glyphName- glyph name- Returns:
- glyph by its name or null if name is not found
-
create
public Glyph create(Enum<?> glyph)
Creates an instance ofGlyphusing a known Glyph enum value- Parameters:
glyph-
-
getCharacter
public Character getCharacter(String glyphName)
Returns the character code which is mapped to this Name. If no match is found, NULL is returned.- Parameters:
glyphName-
-
registerAll
public void registerAll(Iterable<? extends INamedCharacter> namedCharacters)
Registers all given characters with their name.- Parameters:
namedCharacters-
-
-