org.pdfbox.pdmodel.font

Class PDSimpleFont

Implemented Interfaces:
COSObjectable
Known Direct Subclasses:
PDMMType1Font, PDTrueTypeFont, PDType1Font, PDType3Font

public abstract class PDSimpleFont
extends PDFont

This class contains implementation details of the simple pdf fonts.
Version:
$Revision: 1.17 $
Author:
Ben Litchfield

Field Summary

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

font

Constructor Summary

PDSimpleFont()
Constructor.
PDSimpleFont(COSDictionary fontDictionary)
Constructor.

Method Summary

void
drawString(String string, Graphics g, float fontSize, float xScale, float yScale, float x, float y)
float
getAverageFontWidth()
This will get the average font width for all characters.
PDRectangle
getFontBoundingBox()
This will get the fonts bounding box.
PDFontDescriptor
getFontDescriptor()
This will get the font descriptor for this font.
float
getFontHeight(byte[] c, int offset, int length)
This will get the font width for a character.
float
getFontWidth(byte[] c, int offset, int length)
This will get the font width for a character.
PDStream
getToUnicode()
This will get the ToUnicode stream.
void
setFontDescriptor(PDFontDescriptorDictionary fontDescriptor)
This will set the font descriptor.
void
setToUnicode(PDStream unicode)
This will set the ToUnicode stream.

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

Constructor Details

PDSimpleFont

public PDSimpleFont()
Constructor.

PDSimpleFont

public PDSimpleFont(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 PDFont

getAverageFontWidth

public float getAverageFontWidth()
            throws IOException
This will get the average font width for all characters.
Overrides:
getAverageFontWidth in interface PDFont
Returns:
The width is in 1000 unit of text space, ie 333 or 777

getFontBoundingBox

public PDRectangle getFontBoundingBox()
            throws IOException
This will get the fonts bounding box.
Overrides:
getFontBoundingBox in interface PDFont
Returns:
The fonts bouding box.

getFontDescriptor

public PDFontDescriptor getFontDescriptor()
            throws IOException
This will get the font descriptor for this font.
Returns:
The font descriptor for this font.

getFontHeight

public float getFontHeight(byte[] c,
                           int offset,
                           int length)
            throws IOException
This will get the font width for a character.
Overrides:
getFontHeight in interface PDFont
Parameters:
c - The character code to get the width for.
offset - The offset into the array.
length - The length of the data.
Returns:
The width is in 1000 unit of text space, ie 333 or 777

getFontWidth

public float getFontWidth(byte[] c,
                          int offset,
                          int length)
            throws IOException
This will get the font width for a character.
Overrides:
getFontWidth in interface PDFont
Parameters:
c - The character code to get the width for.
offset - The offset into the array.
length - The length of the data.
Returns:
The width is in 1000 unit of text space, ie 333 or 777

getToUnicode

public PDStream getToUnicode()
            throws IOException
This will get the ToUnicode stream.
Returns:
The ToUnicode stream.

setFontDescriptor

public void setFontDescriptor(PDFontDescriptorDictionary fontDescriptor)
This will set the font descriptor.
Parameters:
fontDescriptor - The font descriptor.

setToUnicode

public void setToUnicode(PDStream unicode)
This will set the ToUnicode stream.
Parameters:
unicode - The unicode stream.