Class FlatRobotoFont
- java.lang.Object
-
- com.formdev.flatlaf.fonts.roboto.FlatRobotoFont
-
public class FlatRobotoFont extends Object
The Roboto font family.Font home page: https://fonts.google.com/specimen/Roboto
GitHub project: https://github.com/googlefonts/robotoTo install the font, invoke following once (e.g. in your
main()method; on AWT thread).For lazy loading use:
FlatRobotoFont.installLazy();Or load immediately with:
FlatRobotoFont.install(); // or FlatRobotoFont.installBasic(); FlatRobotoFont.installLight(); FlatRobotoFont.installSemiBold();Use as application font (invoke before setting up FlatLaf):
FlatLaf.setPreferredFontFamily( FlatRobotoFont.FAMILY ); FlatLaf.setPreferredLightFontFamily( FlatRobotoFont.FAMILY_LIGHT ); FlatLaf.setPreferredSemiboldFontFamily( FlatRobotoFont.FAMILY_SEMIBOLD );Create single fonts:
new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY, Font.ITALIC, 12 ); new Font( FlatRobotoFont.FAMILY, Font.BOLD, 12 ); new Font( FlatRobotoFont.FAMILY, Font.BOLD | Font.ITALIC, 12 ); new Font( FlatRobotoFont.FAMILY_LIGHT, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY_LIGHT, Font.ITALIC, 12 ); new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 );If using lazy loading, invoke one of following before creating the font:
FontUtils.loadFontFamily( FlatRobotoFont.FAMILY ); FontUtils.loadFontFamily( FlatRobotoFont.FAMILY_LIGHT ); FontUtils.loadFontFamily( FlatRobotoFont.FAMILY_SEMIBOLD );E.g.:
FontUtils.loadFontFamily( FlatRobotoFont.FAMILY ); Font font = new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 );Or use following:
Font font = FontUtils.getCompositeFont( FlatRobotoFont.FAMILY, Font.PLAIN, 12 );
-
-
Field Summary
Fields Modifier and Type Field Description static StringFAMILYFamily name for basic styles (regular, italic and bold).static StringFAMILY_LIGHTFamily name for light styles.static StringFAMILY_SEMIBOLDFamily name for semibold (medium) styles.static StringSTYLE_BOLDUse forinstallStyle(String)to install single font style.static StringSTYLE_BOLD_ITALICUse forinstallStyle(String)to install single font style.static StringSTYLE_ITALICUse forinstallStyle(String)to install single font style.static StringSTYLE_LIGHTUse forinstallStyle(String)to install single font style.static StringSTYLE_LIGHT_ITALICUse forinstallStyle(String)to install single font style.static StringSTYLE_REGULARUse forinstallStyle(String)to install single font style.static StringSTYLE_SEMIBOLDUse forinstallStyle(String)to install single font style.static StringSTYLE_SEMIBOLD_ITALICUse forinstallStyle(String)to install single font style.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidinstall()Creates and registers the fonts for all styles.static voidinstallBasic()Creates and registers the fonts for basic styles (regular, italic and bold).static voidinstallLazy()Registers the fonts for lazy loading viaFontUtils.registerFontFamilyLoader(String, Runnable).static voidinstallLight()Creates and registers the fonts for light styles.static voidinstallSemiBold()Creates and registers the fonts for semibold (medium) styles.static booleaninstallStyle(String name)Creates and registers the font for the given style.
-
-
-
Field Detail
-
FAMILY
public static final String FAMILY
Family name for basic styles (regular, italic and bold).Usage:
new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY, Font.ITALIC, 12 ); new Font( FlatRobotoFont.FAMILY, Font.BOLD, 12 ); new Font( FlatRobotoFont.FAMILY, Font.BOLD | Font.ITALIC, 12 );- See Also:
- Constant Field Values
-
FAMILY_LIGHT
public static final String FAMILY_LIGHT
Family name for light styles.Usage:
new Font( FlatRobotoFont.FAMILY_LIGHT, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY_LIGHT, Font.ITALIC, 12 );- See Also:
- Constant Field Values
-
FAMILY_SEMIBOLD
public static final String FAMILY_SEMIBOLD
Family name for semibold (medium) styles.Usage:
new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 ); new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 );- See Also:
- Constant Field Values
-
STYLE_REGULAR
public static final String STYLE_REGULAR
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_ITALIC
public static final String STYLE_ITALIC
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_BOLD
public static final String STYLE_BOLD
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_BOLD_ITALIC
public static final String STYLE_BOLD_ITALIC
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_LIGHT
public static final String STYLE_LIGHT
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_LIGHT_ITALIC
public static final String STYLE_LIGHT_ITALIC
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_SEMIBOLD
public static final String STYLE_SEMIBOLD
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
STYLE_SEMIBOLD_ITALIC
public static final String STYLE_SEMIBOLD_ITALIC
Use forinstallStyle(String)to install single font style.- See Also:
- Constant Field Values
-
-
Method Detail
-
installLazy
public static void installLazy()
Registers the fonts for lazy loading viaFontUtils.registerFontFamilyLoader(String, Runnable).This is the preferred method (when using FlatLaf) to avoid unnecessary loading of maybe unused fonts.
Note: When using '
new Font(...)', you need to first invokeFontUtils.loadFontFamily(String)to ensure that the font family is loaded. When FlatLaf loads a font, or when usingFontUtils.getCompositeFont(String, int, int), this is done automatically.
-
install
public static void install()
Creates and registers the fonts for all styles.When using FlatLaf, consider using
installLazy().
-
installBasic
public static void installBasic()
Creates and registers the fonts for basic styles (regular, italic and bold).When using FlatLaf, consider using
installLazy().
-
installLight
public static void installLight()
Creates and registers the fonts for light styles.When using FlatLaf, consider using
installLazy().
-
installSemiBold
public static void installSemiBold()
Creates and registers the fonts for semibold (medium) styles.When using FlatLaf, consider using
installLazy().
-
installStyle
public static boolean installStyle(String name)
Creates and registers the font for the given style. SeeSTYLE_constants.
-
-