Class AbstractFontFileRegistry
- java.lang.Object
-
- org.pentaho.reporting.libraries.fonts.registry.AbstractFontFileRegistry
-
- All Implemented Interfaces:
FontRegistry
- Direct Known Subclasses:
AfmFontRegistry
,PfmFontRegistry
,TrueTypeFontRegistry
public abstract class AbstractFontFileRegistry extends Object implements FontRegistry
Creation-Date: 21.07.2007, 17:01:15- Author:
- Thomas Morgner
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFontFileRegistry()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
addFont(File font, String encoding)
Adds the fontname by creating the basefont object.protected DefaultFontFamily
createFamily(String name)
protected File
createStorageLocation()
String[]
getAllRegisteredFamilies()
protected String
getCacheFileName()
protected String
getDefaultEncoding()
protected abstract FileFilter
getFileFilter()
FontFamily
getFontFamily(String name)
Tries to find a font family with the given name, looking through all alternative font names if neccessary.String[]
getRegisteredFamilies()
protected HashMap<String,FontFileRecord>
getSeenFiles()
void
initialize()
protected boolean
isCached(File file)
protected boolean
isCacheValid(HashMap cachedSeenFiles)
protected void
loadFromCache(String encoding)
protected void
loadFromCache(String encoding, String filename)
protected void
populateFromCache(HashMap<String,DefaultFontFamily> cachedFontFamilies, HashMap<String,DefaultFontFamily> cachedFullFontNames, HashMap<String,DefaultFontFamily> cachedAlternateNames)
protected void
registerAlternativeName(String name, DefaultFontFamily family)
void
registerDefaultFontPath()
Register os-specific font paths to the PDF-FontFactory.void
registerFontFile(File file, String encoding)
void
registerFontFile(String filename, String encoding)
Register the font (must end this *.ttf) to the FontFactory.void
registerFontPath(File file, String encoding)
Register all fonts (*.ttf files) in the given path.protected void
registerFullName(String name, DefaultFontFamily family)
protected void
registerPrimaryName(String name, DefaultFontFamily family)
protected String
safeSystemGetProperty(String name, String defaultValue)
protected void
storeToCache(String encoding)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.reporting.libraries.fonts.registry.FontRegistry
createMetricsFactory, getSecondLevelCache
-
-
-
-
Method Detail
-
getSeenFiles
protected HashMap<String,FontFileRecord> getSeenFiles()
-
getFileFilter
protected abstract FileFilter getFileFilter()
-
initialize
public void initialize()
- Specified by:
initialize
in interfaceFontRegistry
-
getDefaultEncoding
protected String getDefaultEncoding()
-
registerDefaultFontPath
public void registerDefaultFontPath()
Register os-specific font paths to the PDF-FontFactory. For unix-like operating systems, X11 is searched in /usr/X11R6 and the default truetype fontpath is added. For windows the system font path is added (%windir%/fonts)
-
registerPrimaryName
protected void registerPrimaryName(String name, DefaultFontFamily family)
-
registerAlternativeName
protected void registerAlternativeName(String name, DefaultFontFamily family)
-
registerFullName
protected void registerFullName(String name, DefaultFontFamily family)
-
createFamily
protected DefaultFontFamily createFamily(String name)
-
getRegisteredFamilies
public String[] getRegisteredFamilies()
- Specified by:
getRegisteredFamilies
in interfaceFontRegistry
-
getAllRegisteredFamilies
public String[] getAllRegisteredFamilies()
- Specified by:
getAllRegisteredFamilies
in interfaceFontRegistry
-
getFontFamily
public FontFamily getFontFamily(String name)
Description copied from interface:FontRegistry
Tries to find a font family with the given name, looking through all alternative font names if neccessary.- Specified by:
getFontFamily
in interfaceFontRegistry
- Returns:
- the font family or null, if there is no such family.
-
loadFromCache
protected void loadFromCache(String encoding)
-
populateFromCache
protected void populateFromCache(HashMap<String,DefaultFontFamily> cachedFontFamilies, HashMap<String,DefaultFontFamily> cachedFullFontNames, HashMap<String,DefaultFontFamily> cachedAlternateNames)
-
getCacheFileName
protected String getCacheFileName()
-
storeToCache
protected void storeToCache(String encoding)
-
registerFontPath
public void registerFontPath(File file, String encoding)
Register all fonts (*.ttf files) in the given path.- Parameters:
file
- the directory that contains the font files.encoding
- the encoding for the given font.
-
isCached
protected boolean isCached(File file)
-
registerFontFile
public void registerFontFile(String filename, String encoding)
Register the font (must end this *.ttf) to the FontFactory.- Parameters:
filename
- the filename.encoding
- the encoding.
-
addFont
protected abstract boolean addFont(File font, String encoding) throws IOException
Adds the fontname by creating the basefont object. This method tries to load the fonts as embeddable fonts, if this fails, it repeats the loading with the embedded-flag set to false.- Parameters:
font
- the font file name.encoding
- the encoding.- Returns:
- true, if registration was successful, false otherwise.
- Throws:
IOException
- if the base font file could not be read.
-
isCacheValid
protected boolean isCacheValid(HashMap cachedSeenFiles)
-
createStorageLocation
protected File createStorageLocation()
-
-