org.pdfbox.pdmodel.font

Class PDTrueTypeFont

Implemented Interfaces:
COSObjectable

public class PDTrueTypeFont
extends PDSimpleFont

This is the TrueType implementation of fonts.
Version:
$Revision: 1.17 $
Author:
Ben Litchfield

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)
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

drawString, getAverageFontWidth, getFontBoundingBox, getFontDescriptor, getFontHeight, getFontWidth, getToUnicode, setFontDescriptor, setToUnicode

Methods inherited from class org.pdfbox.pdmodel.font.PDFont

clearResources, drawString, encode, equals, getAFM, getAverageFontWidth, getAverageFontWidthFromAFMFile, getBaseFont, getCOSObject, getCodeFromArray, getEncoding, getFirstChar, getFontBoundingBox, getFontHeight, getFontMatrix, getFontWidth, getFontWidthFromAFMFile, getLastChar, getStringWidth, getSubType, getType, getWidths, hashCode, setBaseFont, setEncoding, setFirstChar, setLastChar, setWidths

Field Details

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.

Constructor Details

PDTrueTypeFont

public PDTrueTypeFont()
Constructor.

PDTrueTypeFont

public PDTrueTypeFont(COSDictionary fontDictionary)
Constructor.
Parameters:
fontDictionary - The font dictionary according to the PDF specification.

Method Details

drawString

public void drawString(String string,
                       Graphics g,
                       float fontSize,
                       float xScale,
                       float yScale,
                       float x,
                       float y)
            throws IOException
Overrides:
drawString in interface PDSimpleFont

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.

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.