|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pdfbox.pdmodel.font.PDFont
public abstract class 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(java.lang.String string,
java.awt.Graphics g,
float fontSize,
float xScale,
float yScale,
float x,
float y)
This will draw a string on a canvas using the font. |
java.lang.String |
encode(byte[] c,
int offset,
int length)
This will perform the encoding of a character if needed. |
boolean |
equals(java.lang.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. |
java.lang.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(java.lang.String string)
This will get the width of this string for this font. |
java.lang.String |
getSubType()
This will get the subtype of font, Type1, Type3, ... |
java.lang.String |
getType()
This will always return "Font" for fonts. |
java.util.List |
getWidths()
The widths of the characters. |
int |
hashCode()
|
void |
setBaseFont(java.lang.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(java.util.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 java.io.IOException
c
- The character code to get the width for.offset
- The offset into the array.length
- The length of the data.
java.io.IOException
- If an error occurs while parsing.public abstract float getFontHeight(byte[] c, int offset, int length) throws java.io.IOException
c
- The character code to get the width for.offset
- The offset into the array.length
- The length of the data.
java.io.IOException
- If an error occurs while parsing.public float getStringWidth(java.lang.String string) throws java.io.IOException
string
- The string to get the width of.
java.io.IOException
- If there is an error getting the width information.public abstract float getAverageFontWidth() throws java.io.IOException
java.io.IOException
- If an error occurs while parsing.public abstract void drawString(java.lang.String string, java.awt.Graphics g, float fontSize, float xScale, float yScale, float x, float y) throws java.io.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.
java.io.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 java.io.IOException
code
- The character code we are trying to get.
java.io.IOException
- if we cannot find the width.protected float getAverageFontWidthFromAFMFile() throws java.io.IOException
java.io.IOException
- if we cannot find the width.protected org.fontbox.afm.FontMetric getAFM() throws java.io.IOException
java.io.IOException
- If there is an error getting the AFM object.public java.lang.String encode(byte[] c, int offset, int length) throws java.io.IOException
c
- The character to encode.offset
- The offset into the array to get the datalength
- The number of bytes to read.
java.io.IOException
- If there is an error during the encoding.public void setEncoding(Encoding enc)
enc
- The font encoding.public Encoding getEncoding() throws java.io.IOException
java.io.IOException
- If there is an error getting the encoding.public java.lang.String getType()
public java.lang.String getSubType()
public java.lang.String getBaseFont()
public void setBaseFont(java.lang.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 java.util.List getWidths()
public void setWidths(java.util.List widths)
widths
- The widths of the character codes.public PDMatrix getFontMatrix()
public abstract PDRectangle getFontBoundingBox() throws java.io.IOException
java.io.IOException
- If there is an error getting the bounding box.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |