Class FontFactory


  • public final class FontFactory
    extends java.lang.Object
    Creates font objects for legacy type1 fonts.

    Synchronization

    This class represents a namespace and does not contain instance data or mutable static data. It is therefore threadsafe.
    • Constructor Summary

      Constructors 
      Constructor Description
      FontFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int getNumBytesNeededToIdentify()
      Returns the number of initial bytes necessary to identify a stream as a type1 font
      static int getNumBytesNeededToIdentifyAFM()
      Returns the number of initial bytes necessary to identify a stream as an AFM
      static int getNumBytesNeededToIdentifyPFM()
      Returns the number of initial bytes necessary to identify a stream as a PFM
      static boolean isAFM​(byte[] startingBytes)
      Determines if startingBytes represents the start of an AFM
      static boolean isPFM​(byte[] startingBytes)
      Determines if startingBytes represents the start of a PFM
      static boolean isType1​(byte[] startingBytes)
      Determines if startingBytes represents the start of a type1 font
      static Type1Font[] load​(FontInputStream in, java.net.URL url)
      Given an input stream, creates Type1Font objects that represent it.
      static MetricFile loadAFM​(FontInputStream str, java.net.URL url)
      If the stream contains an AFM, it creates an AFM and returns it.
      static MetricFile loadPFM​(FontInputStream str, java.net.URL url)
      If the stream contains an PFM, it creates an PFM object and returns it.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FontFactory

        public FontFactory()
    • Method Detail

      • getNumBytesNeededToIdentify

        public static int getNumBytesNeededToIdentify()
        Returns the number of initial bytes necessary to identify a stream as a type1 font
      • isType1

        public static boolean isType1​(byte[] startingBytes)
        Determines if startingBytes represents the start of a type1 font
        Parameters:
        startingBytes - The initial file bytes
        Returns:
        true iff the bytes appear to be the start of a type1 font
      • getNumBytesNeededToIdentifyAFM

        public static int getNumBytesNeededToIdentifyAFM()
        Returns the number of initial bytes necessary to identify a stream as an AFM
      • isAFM

        public static boolean isAFM​(byte[] startingBytes)
        Determines if startingBytes represents the start of an AFM
        Parameters:
        startingBytes - The initial file bytes
        Returns:
        true iff the bytes appear to be the start of a afm
      • getNumBytesNeededToIdentifyPFM

        public static int getNumBytesNeededToIdentifyPFM()
        Returns the number of initial bytes necessary to identify a stream as a PFM
      • isPFM

        public static boolean isPFM​(byte[] startingBytes)
        Determines if startingBytes represents the start of a PFM
        Parameters:
        startingBytes - The initial file bytes
        Returns:
        true iff the bytes appear to be the start of a pfm
      • load

        public static Type1Font[] load​(FontInputStream in,
                                       java.net.URL url)
                                throws java.io.IOException,
                                       InvalidFontException,
                                       UnsupportedFontException
        Given an input stream, creates Type1Font objects that represent it. Note that fonts are parsed at this point. Also note that multiple master fonts are not supported by AFE. Calling this function with a multiple master font will cause an exception to be thrown.
        Parameters:
        in - The input stream
        Returns:
        An array of type1 fonts
        Throws:
        java.io.IOException - Thrown if the stream cannot be read
        InvalidFontException - Thrown if the stream does not represent a valid type1 font.
        UnsupportedFontException
      • loadAFM

        public static MetricFile loadAFM​(FontInputStream str,
                                         java.net.URL url)
                                  throws java.io.IOException,
                                         InvalidFontException
        If the stream contains an AFM, it creates an AFM and returns it. Note that AFMs are parsed at this point
        Parameters:
        str - The stream to be probed.
        Returns:
        null if str is not an AFM. A valid AFM object otherwise.
        Throws:
        java.io.IOException - Thrown if the stream cannot be read
        InvalidFontException - Thrown if the stream does not represent a valid AFM
      • loadPFM

        public static MetricFile loadPFM​(FontInputStream str,
                                         java.net.URL url)
                                  throws java.io.IOException,
                                         InvalidFontException
        If the stream contains an PFM, it creates an PFM object and returns it. Note that PFMs are parsed at this point
        Parameters:
        str - The stream to be probed.
        Returns:
        null if str is not an PFM. A valid PFM object otherwise.
        Throws:
        java.io.IOException - Thrown if the stream cannot be read
        InvalidFontException