Class FontUtils


  • public class FontUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      FontUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canChangeSize()  
      static java.awt.Font getFont​(int style)
      Gets the default font with the specified style, correctly scaled
      static java.awt.Font getFont​(int style, FontUtils.Size size)
      Gets the default font with the specified style and size, correctly scaled
      static java.awt.Font getFont​(java.awt.Font font, int style, FontUtils.Size size)
      Gets the specified font with the specified style and size, correctly scaled
      static java.awt.Font getFont​(java.awt.Font font, FontUtils.Size size)
      Gets the specified font with the specified size, correctly scaled
      static java.awt.Font getFont​(java.lang.String name)
      Gets the named font, correctly scaled
      static java.awt.Font getFont​(java.lang.String name, int style)
      Gets the named font with the specified style, correctly scaled
      static java.awt.Font getFont​(FontUtils.FontType fontType)
      Gets the font for the give FontUtils.FontType
      static java.awt.Font getFont​(FontUtils.Size size)
      Gets the default font with the specified size, correctly scaled
      static java.awt.Font getFontWithFallback​(FontUtils.FontType fontType, java.lang.String fallbackFontName)
      Gets font for the given FontUtils.FontType or the fallback font with the given name if no font is set for the given FontType
      static java.awt.Font getQuicksandBoldFont()
      Returns the Quicksand Bold font - https://fonts.google.com/specimen/Quicksand?selection.family=Quicksand
      static float getScale()  
      static java.awt.Font getSystemDefaultFont()  
      static boolean isDefaultFontSet()
      Tells whether or not a custom default font was set.
      static boolean isDefaultFontSet​(FontUtils.FontType fontType)
      Tells whether or not a custom default font was set for the given FontUtils.FontType.
      static void setDefaultFont​(FontUtils.FontType fontType, java.awt.Font font)  
      static void setDefaultFont​(FontUtils.FontType fontType, java.lang.String name, int size)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FontUtils

        public FontUtils()
    • Method Detail

      • getSystemDefaultFont

        public static java.awt.Font getSystemDefaultFont()
      • getQuicksandBoldFont

        public static java.awt.Font getQuicksandBoldFont()
        Returns the Quicksand Bold font - https://fonts.google.com/specimen/Quicksand?selection.family=Quicksand
        Returns:
        the Quicksand Bold font
        Since:
        2.7.0
      • canChangeSize

        public static boolean canChangeSize()
      • setDefaultFont

        public static void setDefaultFont​(FontUtils.FontType fontType,
                                          java.awt.Font font)
      • setDefaultFont

        public static void setDefaultFont​(FontUtils.FontType fontType,
                                          java.lang.String name,
                                          int size)
      • getFont

        public static java.awt.Font getFont​(java.lang.String name)
        Gets the named font, correctly scaled
        Parameters:
        name -
        Returns:
        the named font, correctly scaled
      • getFont

        public static java.awt.Font getFont​(int style)
        Gets the default font with the specified style, correctly scaled
        Parameters:
        style -
        Returns:
        the default font with the specified style, correctly scaled
      • getFont

        public static java.awt.Font getFont​(FontUtils.FontType fontType)
        Gets the font for the give FontUtils.FontType
        Parameters:
        fontType - the FontType for which the font should be returned
        Returns:
        font
      • getFontWithFallback

        public static java.awt.Font getFontWithFallback​(FontUtils.FontType fontType,
                                                        java.lang.String fallbackFontName)
        Gets font for the given FontUtils.FontType or the fallback font with the given name if no font is set for the given FontType
        Parameters:
        fontType - the FontType for which the font should be returned
        fallbackFontName - the name (String) of the font which will be returned of no font is set for the given FontType
        Returns:
        work panels font or fallback font
      • getFont

        public static java.awt.Font getFont​(java.lang.String name,
                                            int style)
        Gets the named font with the specified style, correctly scaled
        Parameters:
        name -
        style -
        Returns:
        the named font with the specified style, correctly scaled
      • getFont

        public static java.awt.Font getFont​(int style,
                                            FontUtils.Size size)
        Gets the default font with the specified style and size, correctly scaled
        Parameters:
        style -
        size -
        Returns:
      • getFont

        public static java.awt.Font getFont​(java.awt.Font font,
                                            int style,
                                            FontUtils.Size size)
        Gets the specified font with the specified style and size, correctly scaled
        Parameters:
        style -
        size -
        Returns:
        Since:
        2.7.0
      • getFont

        public static java.awt.Font getFont​(FontUtils.Size size)
        Gets the default font with the specified size, correctly scaled
        Parameters:
        size -
        Returns:
        the default font with the specified size, correctly scaled
      • getFont

        public static java.awt.Font getFont​(java.awt.Font font,
                                            FontUtils.Size size)
        Gets the specified font with the specified size, correctly scaled
        Parameters:
        font -
        size -
        Returns:
        the specified font with the specified size, correctly scaled
        Since:
        2.7.0
      • getScale

        public static float getScale()
      • isDefaultFontSet

        public static boolean isDefaultFontSet()
        Tells whether or not a custom default font was set.

        If no custom font was set it's used the system default font.

        Returns:
        true if a custom font was set, false otherwise.
        Since:
        2.7.0
        See Also:
        getSystemDefaultFont()