public final class FontCache extends Object implements Serializable
Constructor and Description |
---|
FontCache()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addFont(EmbedFontInfo fontInfo)
Adds a font info to cache
|
void |
clear()
Clears font cache
|
boolean |
containsFont(EmbedFontInfo fontInfo)
is this font info in the cache?
|
boolean |
containsFont(String embedUrl)
is this font in the cache?
|
protected static String |
getCacheKey(EmbedFontInfo fontInfo)
creates a key given a font info for the font mapping
|
static File |
getDefaultCacheFile(boolean forWriting)
Returns the default font cache file.
|
static File |
getFileFromUrls(String[] urls)
Tries to identify a File instance from an array of URLs.
|
org.docx4j.fonts.fop.fonts.FontCache.CachedFontFile |
getFontFile(String embedUrl)
Returns a font from the cache.
|
EmbedFontInfo[] |
getFontInfos(String embedUrl,
long lastModified)
Returns the EmbedFontInfo instances belonging to a font file.
|
static long |
getLastModified(URL url)
Retrieve the last modified date/time of a URL.
|
boolean |
hasChanged()
cache has been updated since it was read
|
boolean |
isFailedFont(String embedUrl,
long lastModified)
has this font previously failed to load?
|
static FontCache |
load()
Reads the default font cache file and returns its contents.
|
static FontCache |
loadFrom(File cacheFile)
Reads a font cache file and returns its contents.
|
void |
registerFailedFont(String embedUrl,
long lastModified)
Registers a failed font with the cache
|
void |
removeFont(String embedUrl)
removes font from cache
|
void |
save()
Writes the font cache to disk.
|
void |
saveTo(File cacheFile)
Writes the font cache to disk.
|
public static File getDefaultCacheFile(boolean forWriting)
forWriting
- true if the user directory should be createdpublic static FontCache load()
public static FontCache loadFrom(File cacheFile)
cacheFile
- the cache filepublic void save() throws FOPException
FOPException
- fop exceptionpublic void saveTo(File cacheFile) throws FOPException
cacheFile
- the file to write toFOPException
- fop exceptionprotected static String getCacheKey(EmbedFontInfo fontInfo)
fontInfo
- font infopublic boolean hasChanged()
public boolean containsFont(String embedUrl)
embedUrl
- font infopublic boolean containsFont(EmbedFontInfo fontInfo)
fontInfo
- font infopublic static File getFileFromUrls(String[] urls)
urls
- array of possible font urlspublic void addFont(EmbedFontInfo fontInfo)
fontInfo
- font infopublic org.docx4j.fonts.fop.fonts.FontCache.CachedFontFile getFontFile(String embedUrl)
embedUrl
- font infopublic EmbedFontInfo[] getFontInfos(String embedUrl, long lastModified)
embedUrl
- the font URLlastModified
- the last modified date/time of the font filepublic void removeFont(String embedUrl)
embedUrl
- embed urlpublic boolean isFailedFont(String embedUrl, long lastModified)
embedUrl
- embed urllastModified
- last modifiedpublic void registerFailedFont(String embedUrl, long lastModified)
embedUrl
- embed urllastModified
- time last modifiedpublic void clear()
public static long getLastModified(URL url)
url
- the URLCopyright © 2007-2016. All Rights Reserved.