org.apache.fop.fonts

Class FontLoader

Known Direct Subclasses:
TTFFontLoader, Type1FontLoader

public abstract class FontLoader
extends java.lang.Object

Base class for font loaders.

Field Summary

protected String
fontFileURI
URI representing the font file
protected InputStream
in
the InputStream to load the font from
protected boolean
loaded
true if the font has been loaded
protected static Log
log
logging instance
protected FontResolver
resolver
the FontResolver to use for font URI resolution
protected CustomFont
returnFont
the loaded font

Constructor Summary

FontLoader(String fontFileURI, InputStream in, FontResolver resolver)
Default constructor.

Method Summary

CustomFont
getFont()
static CustomFont
loadFont(File fontFile, FontResolver resolver)
Loads a custom font from a File.
static CustomFont
loadFont(String fontFileURI, FontResolver resolver)
Loads a custom font from a URI.
protected static CustomFont
loadFontFromInputStream(String fontFileURI, FontResolver resolver, boolean isType1, InputStream in)
Loads and returns a font given an input stream.
protected abstract void
read()
Reads/parses the font data.

Field Details

fontFileURI

protected String fontFileURI
URI representing the font file

in

protected InputStream in
the InputStream to load the font from

loaded

protected boolean loaded
true if the font has been loaded

log

protected static Log log
logging instance

resolver

protected FontResolver resolver
the FontResolver to use for font URI resolution

returnFont

protected CustomFont returnFont
the loaded font

Constructor Details

FontLoader

public FontLoader(String fontFileURI,
                  InputStream in,
                  FontResolver resolver)
Default constructor.
Parameters:
fontFileURI - the URI to the PFB file of a Type 1 font
in - the InputStream reading the PFM file of a Type 1 font
resolver - the font resolver used to resolve URIs

Method Details

getFont

public CustomFont getFont()
            throws IOException
See Also:
getFont()

loadFont

public static CustomFont loadFont(File fontFile,
                                  FontResolver resolver)
            throws IOException
Loads a custom font from a File. In the case of Type 1 fonts, the PFB file must be specified.
Parameters:
fontFile - the File representation of the font
resolver - the font resolver to use when resolving URIs
Returns:
the newly loaded font

loadFont

public static CustomFont loadFont(String fontFileURI,
                                  FontResolver resolver)
            throws IOException
Loads a custom font from a URI. In the case of Type 1 fonts, the PFB file must be specified.
Parameters:
fontFileURI - the URI to the font
resolver - the font resolver to use when resolving URIs
Returns:
the newly loaded font

loadFontFromInputStream

protected static CustomFont loadFontFromInputStream(String fontFileURI,
                                                    FontResolver resolver,
                                                    boolean isType1,
                                                    InputStream in)
            throws IOException
Loads and returns a font given an input stream.
Parameters:
fontFileURI - font file uri
resolver - font resolver
isType1 - is it a type1 font?
in - input stream
Returns:
the loaded font.

read

protected abstract void read()
            throws IOException
Reads/parses the font data.

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.