|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.pdfbox.pdmodel.font.PDFont
This is the base class for all PDF fonts.
| Field Summary | |
protected COSDictionary |
font
The cos dictionary for this font. |
| Constructor Summary | |
PDFont()
Constructor. |
|
PDFont(COSDictionary fontDictionary)
Constructor. |
|
| Method Summary | |
static void |
clearResources()
This will clear AFM resources that are stored statically. |
abstract 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. |
String |
encode(byte[] c,
int offset,
int length)
This will perform the encoding of a character if needed. |
boolean |
equals(Object other)
|
protected org.fontbox.afm.FontMetric |
getAFM()
This will get an AFM object if one exists. |
abstract float |
getAverageFontWidth()
This will get the average font width for all characters. |
protected float |
getAverageFontWidthFromAFMFile()
This will attempt to get the average font width from an AFM file. |
String |
getBaseFont()
The PostScript name of the font. |
protected int |
getCodeFromArray(byte[] data,
int offset,
int length)
Used for multibyte encodings. |
COSBase |
getCOSObject()
Convert this standard java object to a COS object. |
Encoding |
getEncoding()
This will get or create the encoder. |
int |
getFirstChar()
The code for the first char or -1 if there is none. |
abstract PDRectangle |
getFontBoundingBox()
This will get the fonts bouding box. |
abstract float |
getFontHeight(byte[] c,
int offset,
int length)
This will get the font width for a character. |
PDMatrix |
getFontMatrix()
This will get the matrix that is used to transform glyph space to text space. |
abstract float |
getFontWidth(byte[] c,
int offset,
int length)
This will get the font width for a character. |
protected float |
getFontWidthFromAFMFile(int code)
This will attempt to get the font width from an AFM file. |
int |
getLastChar()
The code for the last char or -1 if there is none. |
float |
getStringWidth(String string)
This will get the width of this string for this font. |
String |
getSubType()
This will get the subtype of font, Type1, Type3, ... |
String |
getType()
This will always return "Font" for fonts. |
List |
getWidths()
The widths of the characters. |
int |
hashCode()
|
void |
setBaseFont(String baseFont)
Set the PostScript name of the font. |
void |
setEncoding(Encoding enc)
The will set the encoding for this font. |
void |
setFirstChar(int firstChar)
Set the first character this font supports. |
void |
setLastChar(int lastChar)
Set the last character this font supports. |
void |
setWidths(List widths)
Set the widths of the characters code. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected COSDictionary font
| Constructor Detail |
public PDFont()
public PDFont(COSDictionary fontDictionary)
fontDictionary - The font dictionary according to the PDF specification.| Method Detail |
public static void clearResources()
public COSBase getCOSObject()
getCOSObject in interface COSObjectable
public abstract float getFontWidth(byte[] c,
int offset,
int length)
throws IOException
c - The character code to get the width for.offset - The offset into the array.length - The length of the data.
IOException - If an error occurs while parsing.
public abstract float getFontHeight(byte[] c,
int offset,
int length)
throws IOException
c - The character code to get the width for.offset - The offset into the array.length - The length of the data.
IOException - If an error occurs while parsing.
public float getStringWidth(String string)
throws IOException
string - The string to get the width of.
IOException - If there is an error getting the width information.
public abstract float getAverageFontWidth()
throws IOException
IOException - If an error occurs while parsing.
public abstract void drawString(String string,
Graphics g,
float fontSize,
float xScale,
float yScale,
float x,
float y)
throws IOException
string - The string to draw.g - The graphics to draw onto.fontSize - The size of the font to draw.xScale - The x scaling percent.yScale - The y scaling percent.x - The x coordinate to draw at.y - The y coordinate to draw at.
IOException - If there is an error drawing the specific string.
protected int getCodeFromArray(byte[] data,
int offset,
int length)
data - The array of data.offset - The offset into the array.length - The number of bytes to use.
protected float getFontWidthFromAFMFile(int code)
throws IOException
code - The character code we are trying to get.
IOException - if we cannot find the width.
protected float getAverageFontWidthFromAFMFile()
throws IOException
IOException - if we cannot find the width.
protected org.fontbox.afm.FontMetric getAFM()
throws IOException
IOException - If there is an error getting the AFM object.
public String encode(byte[] c,
int offset,
int length)
throws IOException
c - The character to encode.offset - The offset into the array to get the datalength - The number of bytes to read.
IOException - If there is an error during the encoding.public void setEncoding(Encoding enc)
enc - The font encoding.
public Encoding getEncoding()
throws IOException
IOException - If there is an error getting the encoding.public String getType()
public String getSubType()
public String getBaseFont()
public void setBaseFont(String baseFont)
baseFont - The postscript name for the font.public int getFirstChar()
public void setFirstChar(int firstChar)
firstChar - The first character.public int getLastChar()
public void setLastChar(int lastChar)
lastChar - The last character.public List getWidths()
public void setWidths(List widths)
widths - The widths of the character codes.public PDMatrix getFontMatrix()
public abstract PDRectangle getFontBoundingBox()
throws IOException
IOException - If there is an error getting the bounding box.public boolean equals(Object other)
public int hashCode()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||