Class FontLoader

java.lang.Object
org.apache.fop.fonts.FontLoader
Direct Known Subclasses:
OFFontLoader, Type1FontLoader

public abstract class FontLoader extends Object
Base class for font loaders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    true if the font will be embedded, false if it will be referenced only.
    protected final URI
    URI representing the font file
    protected boolean
    true if the font has been loaded
    protected static final org.apache.commons.logging.Log
    logging instance
    protected final InternalResourceResolver
    the resource resolver to use for font URI resolution
    protected CustomFont
    the loaded font
    protected boolean
    true if advanced typographic information shall be loaded if available.
    protected boolean
    true if kerning information false be loaded if available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FontLoader(URI fontFileURI, boolean embedded, boolean useKerning, boolean useAdvanced, InternalResourceResolver resourceResolver)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the custom font that was read using this instance of FontLoader.
    static CustomFont
    loadFont(FontUris fontUris, String subFontName, boolean embedded, EmbeddingMode embeddingMode, EncodingMode encodingMode, boolean useKerning, boolean useAdvanced, InternalResourceResolver resourceResolver, boolean simulateStyle, boolean embedAsType1, boolean useSVG)
    Loads a custom font from a URI.
    protected abstract void
    Reads/parses the font data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
      logging instance
    • fontFileURI

      protected final URI fontFileURI
      URI representing the font file
    • resourceResolver

      protected final InternalResourceResolver resourceResolver
      the resource resolver to use for font URI resolution
    • returnFont

      protected CustomFont returnFont
      the loaded font
    • loaded

      protected boolean loaded
      true if the font has been loaded
    • embedded

      protected boolean embedded
      true if the font will be embedded, false if it will be referenced only.
    • useKerning

      protected boolean useKerning
      true if kerning information false be loaded if available.
    • useAdvanced

      protected boolean useAdvanced
      true if advanced typographic information shall be loaded if available.
  • Constructor Details

    • FontLoader

      public FontLoader(URI fontFileURI, boolean embedded, boolean useKerning, boolean useAdvanced, InternalResourceResolver resourceResolver)
      Default constructor.
      Parameters:
      fontFileURI - the URI to the PFB file of a Type 1 font
      embedded - indicates whether the font is embedded or referenced
      useKerning - indicates whether kerning information shall be loaded if available
      useAdvanced - indicates whether advanced typographic information shall be loaded if available
      resourceResolver - the font resolver used to resolve URIs
  • Method Details

    • loadFont

      public static CustomFont loadFont(FontUris fontUris, String subFontName, boolean embedded, EmbeddingMode embeddingMode, EncodingMode encodingMode, boolean useKerning, boolean useAdvanced, InternalResourceResolver resourceResolver, boolean simulateStyle, boolean embedAsType1, boolean useSVG) throws IOException
      Loads a custom font from a URI. In the case of Type 1 fonts, the PFB file must be specified.
      Parameters:
      fontUris - the URI to the font
      subFontName - the sub-fontname of a font (for TrueType Collections, null otherwise)
      embedded - indicates whether the font is embedded or referenced
      embeddingMode - the embedding mode of the font
      encodingMode - the requested encoding mode
      useKerning - indicates whether kerning information should be loaded if available
      useAdvanced - indicates whether advanced typographic information shall be loaded if available
      resourceResolver - the font resolver to use when resolving URIs
      Returns:
      the newly loaded font
      Throws:
      IOException - In case of an I/O error
    • read

      protected abstract void read() throws IOException
      Reads/parses the font data.
      Throws:
      IOException - In case of an I/O error
    • getFont

      public CustomFont getFont() throws IOException
      Returns the custom font that was read using this instance of FontLoader.
      Returns:
      the newly loaded font
      Throws:
      IOException - if an I/O error occurs