Class PDFontFactory


  • public final class PDFontFactory
    extends java.lang.Object
    Creates the appropriate font subtype based on information in the dictionary.
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • FONT_TTF_COLLECTION

        private static final java.lang.String FONT_TTF_COLLECTION
        See Also:
        Constant Field Values
      • TTF_HEADER

        private static final byte[] TTF_HEADER
    • Constructor Detail

      • PDFontFactory

        private PDFontFactory()
    • Method Detail

      • createFont

        public static PDFont createFont​(COSDictionary dictionary)
                                 throws java.io.IOException
        Creates a new PDFont instance with the appropriate subclass.
        Parameters:
        dictionary - a font dictionary
        Returns:
        a PDFont instance, based on the SubType entry of the dictionary
        Throws:
        java.io.IOException - if something goes wrong
      • createFont

        public static PDFont createFont​(COSDictionary dictionary,
                                        ResourceCache resourceCache)
                                 throws java.io.IOException
        Creates a new PDFont instance with the appropriate subclass.
        Parameters:
        dictionary - a font dictionary
        resourceCache - resource cache, only useful for type 3 fonts, can be null
        Returns:
        a PDFont instance, based on the SubType entry of the dictionary
        Throws:
        java.io.IOException - if something goes wrong
      • isTrueTypeFile

        private static boolean isTrueTypeFile​(byte[] header)
      • isTrueTypeCollectionFile

        private static boolean isTrueTypeCollectionFile​(byte[] header)
      • isOpenTypeFile

        private static boolean isOpenTypeFile​(byte[] header)
      • isType1File

        private static boolean isType1File​(byte[] header)
      • isPfbFile

        private static boolean isPfbFile​(byte[] header)
      • isCFFFile

        private static boolean isCFFFile​(byte[] header)
      • getFontHeader

        private static byte[] getFontHeader​(COSDictionary fontDescriptor)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • createDescendantFont

        static PDCIDFont createDescendantFont​(COSDictionary dictionary,
                                              PDType0Font parent)
                                       throws java.io.IOException
        Creates a new PDCIDFont instance with the appropriate subclass.
        Parameters:
        dictionary - descendant font dictionary
        Returns:
        a PDCIDFont instance, based on the SubType entry of the dictionary
        Throws:
        java.io.IOException - if something goes wrong