Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.font » [javadoc | source]
org.apache.pdfbox.pdmodel.font
abstract public class: PDFont [javadoc | source]
java.lang.Object
   org.apache.pdfbox.pdmodel.font.PDFont

All Implemented Interfaces:
    COSObjectable

Direct Known Subclasses:
    PDType1CFont, PDTrueTypeFont, PDCIDFontType2Font, PDType1AfmPfbFont, PDType0Font, PDSimpleFont, PDType3Font, PDMMType1Font, PDCIDFontType0Font, PDCIDFont, PDType1Font

This is the base class for all PDF fonts.
Field Summary
protected  COSDictionary font    The cos dictionary for this font. 
Constructor:
 public PDFont() 
 public PDFont(COSDictionary fontDictionary) 
    Constructor.
    Parameters:
    fontDictionary - The font dictionary according to the PDF specification.
Method from org.apache.pdfbox.pdmodel.font.PDFont Summary:
clearResources,   drawString,   encode,   equals,   getAFM,   getAverageFontWidth,   getAverageFontWidthFromAFMFile,   getBaseFont,   getCOSObject,   getCodeFromArray,   getEncoding,   getEncodingManager,   getFirstChar,   getFontBoundingBox,   getFontHeight,   getFontMatrix,   getFontWidth,   getFontWidthFromAFMFile,   getLastChar,   getStringWidth,   getSubType,   getType,   getWidths,   hashCode,   setBaseFont,   setEncoding,   setFirstChar,   setLastChar,   setWidths
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.pdfbox.pdmodel.font.PDFont Detail:
 public static  void clearResources() 
    This will clear AFM resources that are stored statically. This is usually not a problem unless you want to reclaim resources for a long running process. SPECIAL NOTE: The font calculations are currently in COSObject, which is where they will reside until PDFont is mature enough to take them over. PDFont is the appropriate place for them and not in COSObject but we need font calculations for text extractaion. THIS METHOD WILL BE MOVED OR REMOVED TO ANOTHER LOCATION IN A FUTURE VERSION OF PDFBOX.
 abstract public  void drawString(String string,
    Graphics g,
    float fontSize,
    AffineTransform at,
    float x,
    float y) throws IOException
    This will draw a string on a canvas using the font.
 public String encode(byte[] c,
    int offset,
    int length) throws IOException 
    This will perform the encoding of a character if needed.
 public boolean equals(Object other) 
    {@inheritDoc}
 protected FontMetric getAFM() throws IOException 
    This will get an AFM object if one exists.
 abstract public float getAverageFontWidth() throws IOException
    This will get the average font width for all characters.
 protected float getAverageFontWidthFromAFMFile() throws IOException 
    This will attempt to get the average font width from an AFM file.
 public String getBaseFont() 
    The PostScript name of the font.
 public COSBase getCOSObject() 
    {@inheritDoc}
 protected int getCodeFromArray(byte[] data,
    int offset,
    int length) 
    Used for multibyte encodings.
 public Encoding getEncoding() throws IOException 
    This will get or create the encoder. modified by Christophe Huault : DGBS Strasbourg huault@free.fr october 2004
 protected static EncodingManager getEncodingManager() 
 public int getFirstChar() 
    The code for the first char or -1 if there is none.
 abstract public PDRectangle getFontBoundingBox() throws IOException
    This will get the fonts bouding box.
 abstract public float getFontHeight(byte[] c,
    int offset,
    int length) throws IOException
    This will get the font width for a character.
 public PDMatrix getFontMatrix() 
    This will get the matrix that is used to transform glyph space to text space. By default there are 1000 glyph units to 1 text space unit, but type3 fonts can use any value. Note:If this is a type3 font then it can be modified via the PDType3Font.setFontMatrix, otherwise this is a read-only property.
 abstract public float getFontWidth(byte[] c,
    int offset,
    int length) throws IOException
    This will get the font width for a character.
 protected float getFontWidthFromAFMFile(int code) throws IOException 
    This will attempt to get the font width from an AFM file.
 public int getLastChar() 
    The code for the last char or -1 if there is none.
 public float getStringWidth(String string) throws IOException 
    This will get the width of this string for this font.
 public String getSubType() 
    This will get the subtype of font, Type1, Type3, ...
 public String getType() 
    This will always return "Font" for fonts.
 public List getWidths() 
    The widths of the characters. This will be null for the standard 14 fonts.
 public int hashCode() 
    {@inheritDoc}
 public  void setBaseFont(String baseFont) 
    Set the PostScript name of the font.
 public  void setEncoding(Encoding enc) 
    The will set the encoding for this font.
 public  void setFirstChar(int firstChar) 
    Set the first character this font supports.
 public  void setLastChar(int lastChar) 
    Set the last character this font supports.
 public  void setWidths(List widths) 
    Set the widths of the characters code.