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 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, FontResolver resolver)
Default constructor.

Method Summary

CustomFont
getFont()
Returns the custom font that was read using this instance of FontLoader.
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.
static CustomFont
loadFont(URL fontUrl, FontResolver resolver)
Loads a custom font from an URL.
protected static InputStream
openFontUri(FontResolver resolver, String uri)
Opens a font URI and returns an input stream.
protected abstract void
read()
Reads/parses the font data.

Field Details

fontFileURI

protected String fontFileURI
URI representing the font file

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,
                  FontResolver resolver)
Default constructor.
Parameters:
fontFileURI - the URI to the PFB file of a Type 1 font
resolver - the font resolver used to resolve URIs

Method Details

getFont

public CustomFont getFont()
            throws IOException
Returns the custom font that was read using this instance of FontLoader.
Returns:
the newly loaded font

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

loadFont

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

openFontUri

protected static InputStream openFontUri(FontResolver resolver,
                                         String uri)
            throws IOException,
                   MalformedURLException
Opens a font URI and returns an input stream.
Parameters:
resolver - the FontResolver to use for font URI resolution
uri - the URI representing the font
Returns:
the InputStream to read the font from.

read

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

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