Package org.apache.pdfbox.pdmodel.font
Class FontCache
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.FontCache
-
public final class FontCache extends java.lang.ObjectAn in-memory cache for system fonts. This allows PDFBox to manage caching for aFontProvider. PDFBox is free to purge this cache at will.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<FontInfo,java.lang.ref.SoftReference<FontBoxFont>>cache
-
Constructor Summary
Constructors Constructor Description FontCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFont(FontInfo info, FontBoxFont font)Adds the given FontBox font to the cache.FontBoxFontgetFont(FontInfo info)Returns the FontBox font associated with the given FontInfo.
-
-
-
Field Detail
-
cache
private final java.util.Map<FontInfo,java.lang.ref.SoftReference<FontBoxFont>> cache
-
-
Method Detail
-
addFont
public void addFont(FontInfo info, FontBoxFont font)
Adds the given FontBox font to the cache.- Parameters:
info- the FontInfo to be used as keyfont- the font to be cached
-
getFont
public FontBoxFont getFont(FontInfo info)
Returns the FontBox font associated with the given FontInfo.- Parameters:
info- the FontInfo of the cached font- Returns:
- the cached font if available, otherwise null
-
-