Package org.apache.pdfbox.pdmodel.font
Class PDFontFactory
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.PDFontFactory
-
public final class PDFontFactory extends java.lang.ObjectCreates the appropriate font subtype based on information in the dictionary.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPDFontFactory.FontType
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringFONT_OPEN_TYPEprivate static java.lang.StringFONT_TRUE_TYPEprivate static java.lang.StringFONT_TTF_COLLECTIONprivate static java.lang.StringFONT_TYPE1Cprivate static org.apache.commons.logging.LogLOGprivate static byte[]TTF_HEADER
-
Constructor Summary
Constructors Modifier Constructor Description privatePDFontFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static PDCIDFontcreateDescendantFont(COSDictionary dictionary, PDType0Font parent)Creates a new PDCIDFont instance with the appropriate subclass.static PDFontcreateFont(COSDictionary dictionary)Creates a new PDFont instance with the appropriate subclass.static PDFontcreateFont(COSDictionary dictionary, ResourceCache resourceCache)Creates a new PDFont instance with the appropriate subclass.private static voidfixType0Subtype(COSDictionary descendantFont, COSDictionary fontDescriptor, COSName newSubType)private static COSDictionarygetDescendantFont(COSDictionary dictionary)private static COSDictionarygetFontDescriptor(COSDictionary dictionary)private static byte[]getFontHeader(COSDictionary fontDescriptor)private static PDFontFactory.FontTypegetFontTypeFromFont(COSDictionary fontDescriptor, COSName fontType)private static booleanisCFFFile(byte[] header)private static booleanisOpenTypeFile(byte[] header)private static booleanisPfbFile(byte[] header)private static booleanisTrueTypeCollectionFile(byte[] header)private static booleanisTrueTypeFile(byte[] header)private static booleanisType1File(byte[] header)
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
FONT_TYPE1C
private static final java.lang.String FONT_TYPE1C
- See Also:
- Constant Field Values
-
FONT_OPEN_TYPE
private static final java.lang.String FONT_OPEN_TYPE
- See Also:
- Constant Field Values
-
FONT_TTF_COLLECTION
private static final java.lang.String FONT_TTF_COLLECTION
- See Also:
- Constant Field Values
-
FONT_TRUE_TYPE
private static final java.lang.String FONT_TRUE_TYPE
- See Also:
- Constant Field Values
-
TTF_HEADER
private static final byte[] TTF_HEADER
-
-
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 dictionaryresourceCache- 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
-
fixType0Subtype
private static void fixType0Subtype(COSDictionary descendantFont, COSDictionary fontDescriptor, COSName newSubType)
-
getFontTypeFromFont
private static PDFontFactory.FontType getFontTypeFromFont(COSDictionary fontDescriptor, COSName fontType) throws java.io.IOException
- Throws:
java.io.IOException
-
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)
-
getFontDescriptor
private static COSDictionary getFontDescriptor(COSDictionary dictionary)
-
getDescendantFont
private static COSDictionary getDescendantFont(COSDictionary dictionary)
-
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
-
-