org.extex.font
Class FontFactoryImpl

java.lang.Object
  extended by org.extex.framework.AbstractFactory
      extended by org.extex.font.FontFactoryImpl
All Implemented Interfaces:
BackendFontFactory, CoreFontFactory, Configurable, LogEnabled, RegistrarObserver, PropertyAware, ResourceAware, ResourceFinder

public class FontFactoryImpl
extends AbstractFactory
implements CoreFontFactory, ResourceAware, Configurable, PropertyAware, BackendFontFactory, LogEnabled

Factory to load a font. The factory uses a cache (a weak map) to increase the speed.

Version:
$Revision: 6871 $
Author:
Michael Niedermair, Gerd Neugebauer

Field Summary
 
Fields inherited from class org.extex.framework.AbstractFactory
CLASS_ATTRIBUTE, DEFAULT_ATTRIBUTE, SELECT_ATTRIBUTE
 
Constructor Summary
FontFactoryImpl()
          Creates a new object.
 
Method Summary
 void configure(Configuration configuration)
          Configure an object according to a given Configuration.
 BackendFontManager createManager(java.util.List<java.lang.String> fontTypes)
          Create a manager for the back-end font.
 void enableTracing(boolean flag)
          Enable or disable the tracing.
 NamedInputStream findResource(java.lang.String name, java.lang.String type)
          Find a resource which can be used for reading.
 BackendFont getBackendFont(FontKey key)
          Return the font for the backend.
 FontKey getFontKey(FontKey fontKey, FixedDimen size)
          Returns a font key for the font.
 FontKey getFontKey(java.lang.String fontName)
          Returns a font key for the font.
 FontKey getFontKey(java.lang.String fontName, FixedDimen size)
          Returns a font key for the font.
 FontKey getFontKey(java.lang.String fontName, FixedDimen size, java.util.Map<java.lang.String,?> map)
          Returns a font key for the font.
 FontKey getFontKey(java.lang.String fontName, FixedDimen size, java.util.Map<java.lang.String,?> map, java.util.List<java.lang.String> feature)
          Returns a font key for the font.
 ExtexFont getInstance(FontKey key)
          Return a new instance.
 java.util.Properties getProp()
          Getter for prop.
 void setProperties(java.util.Properties properties)
          Setter for the properties.
 void setResourceFinder(ResourceFinder finder)
          Setter for the resource finder.
 
Methods inherited from class org.extex.framework.AbstractFactory
configure, createInstance, createInstance, createInstance, createInstance, createInstanceForConfiguration, createInstanceForConfiguration, createInstanceForConfiguration, enableLogging, enableLogging, getConfiguration, getLogger, getResourceFinder, reconnect, selectConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.extex.framework.logger.LogEnabled
enableLogging
 

Constructor Detail

FontFactoryImpl

public FontFactoryImpl()
Creates a new object.

Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Configure an object according to a given Configuration.

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractFactory
Parameters:
configuration - the configuration object to consider
Throws:
ConfigurationException - in case that something went wrong
See Also:
Configurable.configure( org.extex.framework.configuration.Configuration)

createManager

public BackendFontManager createManager(java.util.List<java.lang.String> fontTypes)
                                 throws ConfigurationException
Create a manager for the back-end font.

Specified by:
createManager in interface CoreFontFactory
Parameters:
fontTypes - the font types, which the back-end can use. The order of the entries in the list determine the preference for the font format. This should be taken into account when several alternatives are possible.
Returns:
the new manager.
Throws:
ConfigurationException - from the configuration system.
See Also:
CoreFontFactory.createManager(java.util.List)

enableTracing

public void enableTracing(boolean flag)
Description copied from interface: ResourceFinder
Enable or disable the tracing. The argument indicates whether tracing should be enabled or disabled. The resource finder can decide on its own how to perform tracing. The preferred way is to write tracing records to a logger.

Specified by:
enableTracing in interface ResourceFinder
Parameters:
flag - indicator whether tracing should be turned on or off.
See Also:
ResourceFinder.enableTracing(boolean)

findResource

public NamedInputStream findResource(java.lang.String name,
                                     java.lang.String type)
                              throws ConfigurationException
Description copied from interface: ResourceFinder
Find a resource which can be used for reading. If the search fails then null is returned.

Specified by:
findResource in interface ResourceFinder
Parameters:
name - the base name of the resource
type - the type, i.e. the extension
Returns:
the file or null if none could be found
Throws:
ConfigurationException - in case of an exception
See Also:
ResourceFinder.findResource(java.lang.String, java.lang.String)

getBackendFont

public BackendFont getBackendFont(FontKey key)
                           throws FontException
Return the font for the backend. If no font is found, then null is returned.

Specified by:
getBackendFont in interface BackendFontFactory
Parameters:
key - the fount key
Returns:
Returns the font instance.
Throws:
FontException - if a font error occurred.
See Also:
BackendFontFactory.getBackendFont(org.extex.font.FontKey)

getFontKey

public FontKey getFontKey(FontKey fontKey,
                          FixedDimen size)
Description copied from interface: CoreFontFactory
Returns a font key for the font.

Specified by:
getFontKey in interface CoreFontFactory
Parameters:
fontKey - the key of the font.
size - the size of the font.
Returns:
the key for the font.
See Also:
CoreFontFactory.getFontKey(org.extex.font.FontKey, org.extex.core.dimen.FixedDimen)

getFontKey

public FontKey getFontKey(java.lang.String fontName)
Returns a font key for the font.

Specified by:
getFontKey in interface CoreFontFactory
Parameters:
fontName - the name of the font.
Returns:
the key for the font.
See Also:
CoreFontFactory.getFontKey(java.lang.String)

getFontKey

public FontKey getFontKey(java.lang.String fontName,
                          FixedDimen size)
Returns a font key for the font.

Specified by:
getFontKey in interface CoreFontFactory
Parameters:
fontName - the name of the font.
size - the size of the font.
Returns:
the key for the font.
See Also:
CoreFontFactory.getFontKey(java.lang.String, org.extex.core.dimen.FixedDimen)

getFontKey

public FontKey getFontKey(java.lang.String fontName,
                          FixedDimen size,
                          java.util.Map<java.lang.String,?> map)
Returns a font key for the font.

Specified by:
getFontKey in interface CoreFontFactory
Parameters:
fontName - the name of the font.
size - the size of the font.
map - the map for the key.
Returns:
the key for the font.
See Also:
CoreFontFactory.getFontKey(java.lang.String, org.extex.core.dimen.FixedDimen, java.util.Map)

getFontKey

public FontKey getFontKey(java.lang.String fontName,
                          FixedDimen size,
                          java.util.Map<java.lang.String,?> map,
                          java.util.List<java.lang.String> feature)
Returns a font key for the font.

Specified by:
getFontKey in interface CoreFontFactory
Parameters:
fontName - the name of the font.
size - the size of the font.
map - the map for the key.
feature - the list of features.
Returns:
the key for the font.
See Also:
CoreFontFactory.getFontKey(java.lang.String, org.extex.core.dimen.FixedDimen, java.util.Map, java.util.List)

getInstance

public ExtexFont getInstance(FontKey key)
                      throws ConfigurationException,
                             FontException
Return a new instance. If the name is empty or null, then the NullFont are returned. If the font is found in the cache, the cached object is returned, otherwise, the font is loaded from a file.

Specified by:
getInstance in interface CoreFontFactory
Parameters:
key - the fount key
Returns:
the new font instance.
Throws:
ConfigurationException - from the resource finder.
FontException - if a font-error occurred.

getProp

public java.util.Properties getProp()
Getter for prop.

Returns:
the prop

setProperties

public void setProperties(java.util.Properties properties)
Description copied from interface: PropertyAware
Setter for the properties.

Specified by:
setProperties in interface PropertyAware
Parameters:
properties - the properties to use for configuration
See Also:
PropertyAware.setProperties(java.util.Properties)

setResourceFinder

public void setResourceFinder(ResourceFinder finder)
Description copied from class: AbstractFactory
Setter for the resource finder.

Specified by:
setResourceFinder in interface ResourceAware
Overrides:
setResourceFinder in class AbstractFactory
Parameters:
finder - the resource finder
See Also:
ResourceAware.setResourceFinder( org.extex.resource.ResourceFinder)