Class FlatRobotoFont


  • public class FlatRobotoFont
    extends java.lang.Object
    The Roboto font family.

    Font home page: https://fonts.google.com/specimen/Roboto
    GitHub project: https://github.com/googlefonts/roboto

    To 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 Detail

      • FAMILY

        public static final java.lang.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 java.lang.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 java.lang.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
    • Constructor Detail

      • FlatRobotoFont

        private FlatRobotoFont()
    • Method Detail

      • 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​(java.lang.String name)
        Creates and registers the font for the given style. See STYLE_ constants.