org.apache.fop.pdf

Class PDFFont

Implemented Interfaces:
PDFWritable
Known Direct Subclasses:
PDFFontNonBase14

public class PDFFont
extends PDFObject

Class representing a /Font object.

A more complete object expressing the base font name and encoding of a font along with an internal name for the font used within streams of content.

Fonts are specified on page 198 and onwards of the PDF 1.3 spec.

Field Summary

protected String
basefont
the base font name (eg "Helvetica")
protected Object
encoding
the character encoding scheme used by the font.
protected String
fontname
the internal name for the font (eg "F1")
protected FontType
subtype
the font's subtype (as defined by the constants FontType: TYPE0, TYPE1, MMTYPE1, TYPE3, TRUETYPE)

Fields inherited from class org.apache.fop.pdf.PDFObject

DATE_FORMAT, log

Constructor Summary

PDFFont(String fontname, FontType subtype, String basefont, Object encoding)
create the /Font object

Method Summary

static PDFFont
createFont(String fontname, FontType subtype, String basefont, Object encoding)
factory method with the basic parameters
static PDFFont
createFont(String fontname, FontType subtype, String basefont, Object encoding, int firstChar, int lastChar, PDFArray widths, PDFFontDescriptor descriptor)
factory method with the extended parameters for Type1, MMType1 and TrueType
protected void
fillInPDF(StringBuffer target)
This method is called to receive the specifics for the font's subtype.
String
getName()
get the internal name used for this font
protected String
getPDFNameForFontType(FontType fontType)
Returns the PDF name for a certain font type.
String
toPDFString()
protected void
validate()
Validates the PDF object prior to serialization.

Methods inherited from class org.apache.fop.pdf.PDFObject

encode, encodeString, encodeText, formatDateTime, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, hasObjectNumber, makeReference, output, referencePDF, setDocument, setObjectNumber, toInlinePDFString, toPDF, toPDFString

Field Details

basefont

protected String basefont
the base font name (eg "Helvetica")

encoding

protected Object encoding
the character encoding scheme used by the font. It can be a String for standard encodings, or a PDFEncoding for a more complex scheme, or a PDFStream containing a CMap in a Type0 font. If null then not written out in the PDF.

fontname

protected String fontname
the internal name for the font (eg "F1")

subtype

protected FontType subtype
the font's subtype (as defined by the constants FontType: TYPE0, TYPE1, MMTYPE1, TYPE3, TRUETYPE)

Constructor Details

PDFFont

public PDFFont(String fontname,
               FontType subtype,
               String basefont,
               Object encoding)
create the /Font object
Parameters:
fontname - the internal name for the font
subtype - the font's subtype
basefont - the base font name
encoding - the character encoding schema used by the font

Method Details

createFont

public static PDFFont createFont(String fontname,
                                 FontType subtype,
                                 String basefont,
                                 Object encoding)
factory method with the basic parameters
Parameters:
fontname - the internal name for the font
subtype - the font's subtype
basefont - the base font name
encoding - the character encoding schema used by the font
Returns:
the generated PDFFont object

createFont

public static PDFFont createFont(String fontname,
                                 FontType subtype,
                                 String basefont,
                                 Object encoding,
                                 int firstChar,
                                 int lastChar,
                                 PDFArray widths,
                                 PDFFontDescriptor descriptor)
factory method with the extended parameters for Type1, MMType1 and TrueType
Parameters:
fontname - the internal name for the font
subtype - the font's subtype
basefont - the base font name
encoding - the character encoding schema used by the font
firstChar - the first character code in the font
lastChar - the last character code in the font
widths - an array of size (lastChar - firstChar +1)
descriptor - the descriptor for other font's metrics
Returns:
the generated PDFFont object

fillInPDF

protected void fillInPDF(StringBuffer target)
This method is called to receive the specifics for the font's subtype.

The given buffer already contains the fields common to all font types.

Parameters:
target - the buffer to be completed with the type specific fields

getName

public String getName()
get the internal name used for this font
Returns:
the internal name

getPDFNameForFontType

protected String getPDFNameForFontType(FontType fontType)
Returns the PDF name for a certain font type.
Parameters:
fontType - font type
Returns:
String corresponding PDF name

toPDFString

public String toPDFString()
Overrides:
toPDFString in interface PDFObject

validate

protected void validate()
Validates the PDF object prior to serialization.

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