java.lang.Objectcom.pdfjet.Font
public class Font
Used to create font objects. The font objects must added to the PDF before they can be used to draw text.
Field Summary | |
---|---|
static java.lang.String |
AdobeMingStd_Light
|
static java.lang.String |
AdobeMyungjoStd_Medium
|
boolean |
isDevanagari
|
static java.lang.String |
KozMinProVI_Regular
|
static java.lang.String |
STHeitiSC_Light
|
static boolean |
STREAM
|
Constructor Summary | |
---|---|
Font(PDF pdf,
CoreFont coreFont)
Constructor for the 14 standard fonts. |
|
Font(PDF pdf,
java.io.InputStream inputStream)
|
|
Font(PDF pdf,
java.io.InputStream inputStream,
boolean flag)
|
|
Font(PDF pdf,
java.io.InputStream inputStream,
int codePage,
boolean embed)
Constructor for OpenType and TrueType fonts. |
|
Font(PDF pdf,
java.lang.String fontName)
|
|
Font(PDF pdf,
java.lang.String fontName,
int codePage)
Constructor for CJK - Chinese, Japanese and Korean fonts. |
Method Summary | |
---|---|
float |
getAscent()
Returns the ascent of this font. |
float |
getBodyHeight()
Returns the height of the body of the font. |
float |
getDescent()
Returns the descent of this font. |
int |
getFitChars(java.lang.String str,
double width)
Returns the number of characters from the specified string that will fit within the specified width. |
int |
getFitChars(java.lang.String str,
float width)
Returns the number of characters from the specified string that will fit within the specified width. |
float |
getHeight()
Returns the height of this font. |
float |
getSize()
Returns the current font size. |
float |
getUnderlinePosition()
|
float |
getUnderlineThickness()
|
void |
setItalic(boolean skew15)
Sets the skew15 private variable. |
void |
setKernPairs(boolean kernPairs)
Sets the kerning for the selected font to 'true' or 'false' depending on the passed value of kernPairs parameter. |
Font |
setSize(double fontSize)
Sets the size of this font. |
Font |
setSize(float fontSize)
Sets the size of this font. |
float |
stringWidth(Font font2,
java.lang.String str)
Returns the width of a string drawn using two fonts. |
float |
stringWidth(java.lang.String str)
Returns the width of the specified string when drawn on the page with this font using the current font size. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String AdobeMingStd_Light
public static final java.lang.String STHeitiSC_Light
public static final java.lang.String KozMinProVI_Regular
public static final java.lang.String AdobeMyungjoStd_Medium
public static final boolean STREAM
public boolean isDevanagari
Constructor Detail |
---|
public Font(PDF pdf, CoreFont coreFont) throws java.lang.Exception
Examples: Font font1 = new Font(pdf, CoreFont.HELVETICA); Font font2 = new Font(pdf, CoreFont.TIMES_ITALIC); Font font3 = new Font(pdf, CoreFont.ZAPF_DINGBATS); ...
pdf
- the PDF to add this font to.coreFont
- the core font. Must be one the names defined in the CoreFont class.
java.lang.Exception
public Font(PDF pdf, java.lang.String fontName) throws java.lang.Exception
java.lang.Exception
public Font(PDF pdf, java.lang.String fontName, int codePage) throws java.lang.Exception
pdf
- the PDF to add this font to.fontName
- the font name. Please see Example_04.codePage
- the code page. Must be: CodePage.UNICODE
java.lang.Exception
public Font(PDF pdf, java.io.InputStream inputStream, boolean flag) throws java.lang.Exception
java.lang.Exception
public Font(PDF pdf, java.io.InputStream inputStream) throws java.lang.Exception
java.lang.Exception
public Font(PDF pdf, java.io.InputStream inputStream, int codePage, boolean embed) throws java.lang.Exception
pdf
- the PDF object that requires this font.inputStream
- the input stream to read this font from.codePage
- must be:
CodePage.UNICODE
embed
- specifies if this font must be embedded in the PDF file.
java.lang.Exception
Method Detail |
---|
public float getUnderlinePosition()
public float getUnderlineThickness()
public Font setSize(double fontSize)
fontSize
- specifies the size of this font.
public Font setSize(float fontSize)
fontSize
- specifies the size of this font.
public float getSize()
public void setKernPairs(boolean kernPairs)
kernPairs
- if 'true' the kerning for this font is enabled.public float stringWidth(java.lang.String str)
str
- the specified string.
public float getAscent()
public float getDescent()
public float getHeight()
public float getBodyHeight()
public int getFitChars(java.lang.String str, double width)
str
- the specified string.width
- the specified width.
public int getFitChars(java.lang.String str, float width)
str
- the specified string.width
- the specified width.
public void setItalic(boolean skew15)
skew15
- the skew flag.public float stringWidth(Font font2, java.lang.String str)
font2
- the fallback font.str
- the string.