Class FontUtils

java.lang.Object
com.jidesoft.swing.FontUtils

public class FontUtils extends Object
This is a global class to keep a record of Font so that we can improve the performance and memory usage in various scenarios like StyledLabel.

In this class, we have a global map of font and derived font. It probably could be huge after running a long time. In that case, you need explicitly clear the font cache in this class by using clearDerivedFontCache() .

  • Constructor Details

    • FontUtils

      public FontUtils()
  • Method Details

    • getDerivedFontCacheSize

      public static int getDerivedFontCacheSize()
      Gets the derived font cache size.
      Returns:
      the derived font cache size.
    • clearDerivedFontCache

      public static void clearDerivedFontCache()
      Clear cache whenever needed.
    • getCachedDerivedFont

      public static Font getCachedDerivedFont(Font font, int style, int size)
      Get derived font by font, style and size. At first it will get the derived font from cache. If it cannot hit the derived font, it will invoke font.deriveFont to derive a font.
      Parameters:
      font - the original font
      style - the font style
      size - the font size
      Returns:
      the derived font.