Class FontCache

java.lang.Object
com.itextpdf.io.font.FontCache

public class FontCache extends Object
Caches font programs by their source identifiers.
  • Constructor Details

    • FontCache

      public FontCache()
  • Method Details

    • clearSavedFonts

      public static void clearSavedFonts()
      Clears the cache by removing fonts that were added via saveFont(FontProgram, String).

      Be aware that in multithreading environment this method call will affect the result of getFont(String). This in its turn affects creation of fonts via factories when cached argument is set to true (which is by default).

    • getFont

      public static FontProgram getFont (String fontName)
      Retrieves a cached font by its source name.
      Parameters:
      fontName - the font source name
      Returns:
      the cached font, or null when absent
    • saveFont

      public static FontProgram saveFont (FontProgram font, String fontName)
      Caches a font unless an entry for the source name already exists.
      Parameters:
      font - the font to cache
      fontName - the font source name
      Returns:
      the cached font, which may be an existing entry