org.pdfbox.pdmodel.font
Class PDTrueTypeFont

java.lang.Object
  extended byorg.pdfbox.pdmodel.font.PDFont
      extended byorg.pdfbox.pdmodel.font.PDSimpleFont
          extended byorg.pdfbox.pdmodel.font.PDTrueTypeFont
All Implemented Interfaces:
COSObjectable

public class PDTrueTypeFont
extends PDSimpleFont

This is the TrueType implementation of fonts.

Version:
$Revision: 1.14 $
Author:
Ben Litchfield (ben@benlitchfield.com)

Field Summary
static String UNKNOWN_FONT
          This is the key to a property in the Resources/PDFBox_External_Fonts.properties file to load a Font when a mapping does not exist for the current font.
 
Fields inherited from class org.pdfbox.pdmodel.font.PDFont
font
 
Constructor Summary
PDTrueTypeFont()
          Constructor.
PDTrueTypeFont(COSDictionary fontDictionary)
          Constructor.
 
Method Summary
 void drawString(String string, Graphics g, float fontSize, float xScale, float yScale, float x, float y)
          This will draw a string on a canvas using the font.
static PDTrueTypeFont loadTTF(PDDocument doc, File file)
          This will load a TTF to be embedding into a document.
static PDTrueTypeFont loadTTF(PDDocument doc, String file)
          This will load a TTF font from a font file.
 
Methods inherited from class org.pdfbox.pdmodel.font.PDSimpleFont
getAverageFontWidth, getFontBoundingBox, getFontDescriptor, getFontWidth, getToUnicode, setFontDescriptor, setToUnicode
 
Methods inherited from class org.pdfbox.pdmodel.font.PDFont
clearResources, encode, equals, getAFM, getAverageFontWidthFromAFMFile, getBaseFont, getCodeFromArray, getCOSObject, getEncoding, getFirstChar, getFontMatrix, getFontWidthFromAFMFile, getLastChar, getStringWidth, getSubType, getType, getWidths, hashCode, setBaseFont, setEncoding, setFirstChar, setLastChar, setWidths
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_FONT

public static final String UNKNOWN_FONT
This is the key to a property in the Resources/PDFBox_External_Fonts.properties file to load a Font when a mapping does not exist for the current font.

See Also:
Constant Field Values
Constructor Detail

PDTrueTypeFont

public PDTrueTypeFont()
Constructor.


PDTrueTypeFont

public PDTrueTypeFont(COSDictionary fontDictionary)
Constructor.

Parameters:
fontDictionary - The font dictionary according to the PDF specification.
Method Detail

loadTTF

public static PDTrueTypeFont loadTTF(PDDocument doc,
                                     String file)
                              throws IOException
This will load a TTF font from a font file.

Parameters:
doc - The PDF document that will hold the embedded font.
file - The file on the filesystem that holds the font file.
Returns:
A true type font.
Throws:
IOException - If there is an error loading the file data.

loadTTF

public static PDTrueTypeFont loadTTF(PDDocument doc,
                                     File file)
                              throws IOException
This will load a TTF to be embedding into a document.

Parameters:
doc - The PDF document that will hold the embedded font.
file - A TTF file stream.
Returns:
A PDF TTF.
Throws:
IOException - If there is an error loading the data.

drawString

public void drawString(String string,
                       Graphics g,
                       float fontSize,
                       float xScale,
                       float yScale,
                       float x,
                       float y)
                throws IOException
Description copied from class: PDFont
This will draw a string on a canvas using the font.

Overrides:
drawString in class PDSimpleFont
Throws:
IOException
See Also:
PDFont.drawString( String, Graphics, float, float, float, float, float )