Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.font

public final Class FontCache

extends Object
Class Inheritance
Imports
java.lang.ref.SoftReference, java.util.Map, java.util.concurrent.ConcurrentHashMap, org.apache.fontbox.FontBoxFont

An in-memory cache for system fonts. This allows PDFBox to manage caching for a FontProvider. PDFBox is free to purge this cache at will.
Author
John Hewson

Field Summary

Modifier and TypeField and Description
private final Map<FontInfo, SoftReference<FontBoxFont>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addFont(FontInfo
the FontInfo to be used as key
info
,
FontBoxFont
the font to be cached
font
)

Adds the given FontBox font to the cache.

public FontBoxFont

Returns:

the cached font if available, otherwise null
getFont
(FontInfo
the FontInfo of the cached font
info
)

Returns the FontBox font associated with the given FontInfo.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final Map<FontInfo, SoftReference<FontBoxFont>> cache

Constructor Detail

FontCacheback to summary
public FontCache()

Method Detail

addFontback to summary
public void addFont(FontInfo info, FontBoxFont font)

Adds the given FontBox font to the cache.

Parameters
info:FontInfo

the FontInfo to be used as key

font:FontBoxFont

the font to be cached

getFontback to summary
public FontBoxFont getFont(FontInfo info)

Returns the FontBox font associated with the given FontInfo.

Parameters
info:FontInfo

the FontInfo of the cached font

Returns:FontBoxFont

the cached font if available, otherwise null