net.sourceforge.jeuclid.font
Class DefaultFontFactory

java.lang.Object
  extended by net.sourceforge.jeuclid.font.FontFactory
      extended by net.sourceforge.jeuclid.font.DefaultFontFactory

public class DefaultFontFactory
extends FontFactory

Concrete FontFactory implementation that does simple caching of Fonts loaded via Font.createFont(int, File) APIs.

Version:
$Revision: 600 $
Author:
Ernest Mishkin

Method Summary
protected  Font cacheFont(Font font)
          Actually stores a font in the cache.
 Font getFont(List<String> preferredFonts, int codepoint, int style, int size)
          Create a font object which is able to display the requested code point.
 Font getFont(String name, int style, int size)
          Create a font object with specified properties.
 Font registerFont(int format, File fontFile)
          Load an external font from a file and 'register' (aka 'cache') it for future use.
 Font registerFont(int format, InputStream fontStream)
          Load an external font from a stream and 'register' (aka 'cache') it for future use.
 
Methods inherited from class net.sourceforge.jeuclid.font.FontFactory
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFont

public Font getFont(String name,
                    int style,
                    int size)
Create a font object with specified properties. Font name may refer to either 'built-in' or loaded externally and 'cached' font.

Specified by:
getFont in class FontFactory
Parameters:
name - font name or font family name
style - font style
size - font size
Returns:
Font instance
See Also:
Font.Font(String, int, int)

getFont

public Font getFont(List<String> preferredFonts,
                    int codepoint,
                    int style,
                    int size)
Create a font object which is able to display the requested code point. Uses one of the list of preferred fonts is possible. If no matching font is found a generic font is returned.

Specified by:
getFont in class FontFactory
Parameters:
preferredFonts - List of preferred fonts
codepoint - code point which must be displayable
style - font style
size - font size
Returns:
a valid Font instance

registerFont

public Font registerFont(int format,
                         File fontFile)
                  throws IOException,
                         FontFormatException
Load an external font from a file and 'register' (aka 'cache') it for future use.

Specified by:
registerFont in class FontFactory
Parameters:
format - font format (TTF or TYPE_1 currently supported by the platform)
fontFile - file which contains the font
Returns:
The newly created Font instance
Throws:
FontFormatException - if font contained in the file doesn't match the specified format
IOException - in case of problem while reading the file
See Also:
Font.createFont(int, File)

registerFont

public Font registerFont(int format,
                         InputStream fontStream)
                  throws IOException,
                         FontFormatException
Load an external font from a stream and 'register' (aka 'cache') it for future use.

Specified by:
registerFont in class FontFactory
Parameters:
format - font format (TTF or TYPE_1 currently supported by the platform)
fontStream - file which contains the font
Returns:
The newly created Font instance
Throws:
FontFormatException - if font contained in the stream doesn't match the specified format
IOException - in case of problem while reading the stream
See Also:
Font.createFont(int, InputStream)

cacheFont

protected Font cacheFont(Font font)
Actually stores a font in the cache. Uses font name and font family as keys.

Parameters:
font - Font instance to cache
Returns:
the font instance that was cached


Copyright © 2002-2008 The JEuclid project. All Rights Reserved.