Package com.formdev.flatlaf.util
Class FontUtils
java.lang.Object
com.formdev.flatlaf.util.FontUtils
Utility methods for fonts.
- Since:
- 3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Font[]
Returns all fonts available in the graphics environment.static String[]
Returns all font family names available in the graphics environment.static Font
getCompositeFont
(String family, int style, int size) Gets a composite font for the given family, style and size.private static boolean
static boolean
installFont
(URL url) Loads a font file from the given url and registers it in the graphics environment.static void
loadFontFamily
(String family) Loads a font family previously registered viaregisterFontFamilyLoader(String, Runnable)
.static void
registerFontFamilyLoader
(String family, Runnable loader) Registers a font family for lazy loading vialoadFontFamily(String)
.
-
Field Details
-
loadersMap
-
-
Constructor Details
-
FontUtils
public FontUtils()
-
-
Method Details
-
getCompositeFont
Gets a composite font for the given family, style and size. A composite font that is able to display all Unicode characters. The font family is loaded if necessary vialoadFontFamily(String)
.To get fonts derived from returned fonts, it is recommended to use one of the
Font.deriveFont(int, float)
methods instead of invoking this method. -
registerFontFamilyLoader
Registers a font family for lazy loading vialoadFontFamily(String)
.The given runnable is invoked when the given font family should be loaded. The runnable should invoke
installFont(URL)
to load and register font(s) for the family. A family may consist of up to four font files for the supported font styles: regular (plain), italic, bold and bold-italic. -
loadFontFamily
Loads a font family previously registered viaregisterFontFamilyLoader(String, Runnable)
. If the family is already loaded or no loader is registered for that family, nothing happens. -
installFont
Loads a font file from the given url and registers it in the graphics environment. UsesFont.createFont(int, InputStream)
andGraphicsEnvironment.registerFont(Font)
. -
getAvailableFontFamilyNames
Returns all font family names available in the graphics environment. This invokesGraphicsEnvironment.getAvailableFontFamilyNames()
and appends families registered for lazy loading viaregisterFontFamilyLoader(String, Runnable)
to the result. -
getAllFonts
Returns all fonts available in the graphics environment. This first loads all families registered for lazy loading viaregisterFontFamilyLoader(String, Runnable)
and then invokesGraphicsEnvironment.getAllFonts()
. -
hasLoaders
private static boolean hasLoaders()
-