org.pentaho.reporting.libraries.fonts.registry
Class AbstractFontFileRegistry

java.lang.Object
  extended by org.pentaho.reporting.libraries.fonts.registry.AbstractFontFileRegistry
All Implemented Interfaces:
FontRegistry
Direct Known Subclasses:
AfmFontRegistry, PfmFontRegistry, TrueTypeFontRegistry

public abstract class AbstractFontFileRegistry
extends java.lang.Object
implements FontRegistry

Creation-Date: 21.07.2007, 17:01:15

Author:
Thomas Morgner

Constructor Summary
protected AbstractFontFileRegistry()
           
 
Method Summary
protected abstract  boolean addFont(java.io.File font, java.lang.String encoding)
          Adds the fontname by creating the basefont object.
protected  java.io.File createStorageLocation()
           
protected  java.lang.String getDefaultEncoding()
           
protected abstract  java.io.FileFilter getFileFilter()
           
protected  java.util.HashMap getSeenFiles()
           
 void initialize()
           
protected  boolean isCached(java.io.File file)
           
protected  boolean isCacheValid(java.util.HashMap cachedSeenFiles)
           
protected  void loadFromCache(java.lang.String encoding)
           
 void registerDefaultFontPath()
          Register os-specific font paths to the PDF-FontFactory.
 void registerFontFile(java.io.File file, java.lang.String encoding)
           
 void registerFontFile(java.lang.String filename, java.lang.String encoding)
          Register the font (must end this *.ttf) to the FontFactory.
 void registerFontPath(java.io.File file, java.lang.String encoding)
          Register all fonts (*.ttf files) in the given path.
protected  java.lang.String safeSystemGetProperty(java.lang.String name, java.lang.String defaultValue)
           
protected  void storeToCache(java.lang.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, getAllRegisteredFamilies, getFontFamily, getRegisteredFamilies, getSecondLevelCache
 

Constructor Detail

AbstractFontFileRegistry

protected AbstractFontFileRegistry()
Method Detail

getSeenFiles

protected java.util.HashMap getSeenFiles()

getFileFilter

protected abstract java.io.FileFilter getFileFilter()

initialize

public void initialize()
Specified by:
initialize in interface FontRegistry

getDefaultEncoding

protected java.lang.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)


storeToCache

protected void storeToCache(java.lang.String encoding)

loadFromCache

protected void loadFromCache(java.lang.String encoding)

registerFontPath

public void registerFontPath(java.io.File file,
                             java.lang.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(java.io.File file)

registerFontFile

public void registerFontFile(java.lang.String filename,
                             java.lang.String encoding)
Register the font (must end this *.ttf) to the FontFactory.

Parameters:
filename - the filename.
encoding - the encoding.

registerFontFile

public void registerFontFile(java.io.File file,
                             java.lang.String encoding)

addFont

protected abstract boolean addFont(java.io.File font,
                                   java.lang.String encoding)
                            throws java.io.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.
Throws:
java.io.IOException - if the base font file could not be read.

safeSystemGetProperty

protected java.lang.String safeSystemGetProperty(java.lang.String name,
                                                 java.lang.String defaultValue)

isCacheValid

protected boolean isCacheValid(java.util.HashMap cachedSeenFiles)

createStorageLocation

protected java.io.File createStorageLocation()