Package com.itextpdf.io.font
Class FontCache
java.lang.Object
com.itextpdf.io.font.FontCache
Caches font programs by their source identifiers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the cache by removing fonts that were added viasaveFont(FontProgram, String).static FontProgramRetrieves a cached font by its source name.static FontProgramsaveFont(FontProgram font, String fontName) Caches a font unless an entry for the source name already exists.
-
Constructor Details
-
FontCache
public FontCache()
-
-
Method Details
-
clearSavedFonts
public static void clearSavedFonts()Clears the cache by removing fonts that were added viasaveFont(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 whencachedargument is set to true (which is by default). -
getFont
Retrieves a cached font by its source name.- Parameters:
-
fontName- the font source name - Returns:
-
the cached font, or
nullwhen absent
-
saveFont
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
-