public class Font
extends java.lang.Object
Font
represents a PDF font.
The Font
class represents the PDF Font. This class provides
methods for application to obtain some specifications of a font, like font
name, font style etc.
It can be constructed by the following ways.
Example:
Font font = Font.createStandard(int);
Font font = Font.create(final String, int, int, int);
Font font = Font.createFromFile(final FileHandler, int, int);
Modifier and Type | Class and Description |
---|---|
static class |
Font.FontFace
FontFace is an inner class defined for a Font Face object. |
Modifier and Type | Field and Description |
---|---|
static int |
CHARSET_ANSI
ANSI (United States, Western Europe), default 0.
|
static int |
CHARSET_ARABIC
Arabic, default 178.
|
static int |
CHARSET_BALTIC
Baltic, default 186.
|
static int |
CHARSET_CHINESEBIG5
Traditional Chinese, default 136.
|
static int |
CHARSET_DEFAULT
System default, for unknown or mapping purpose, default 1.
|
static int |
CHARSET_EASTEUROPE
Eastern European, default 238.
|
static int |
CHARSET_GB2312
Simplified Chinese, default 134.
|
static int |
CHARSET_GREEK
Greek, default 161.
|
static int |
CHARSET_HANGEUL
Korean (Wansung), default 129.
|
static int |
CHARSET_HEBREW
Hebrew, default 177.
|
static int |
CHARSET_RUSSIAN
Russian, default 204.
|
static int |
CHARSET_SHIFTJIS
Japanese (Shift-JIS), default 128.
|
static int |
CHARSET_SYMBOL
Standard symbols, default 2.
|
static int |
CHARSET_THAI
Thai, default 222.
|
static int |
CHARSET_TURKISH
Turkish, default 162.
|
static int |
FONTSTYLE_ALLCAP
All cap.
|
static int |
FONTSTYLE_BOLD
Force bold.
|
static int |
FONTSTYLE_FIXEDPITCH
Fixed pitch.
|
static int |
FONTSTYLE_ITALIC
Italic.
|
static int |
FONTSTYLE_NONSYMBOLIC
Non-symbolic.
|
static int |
FONTSTYLE_SCRIPT
Script.
|
static int |
FONTSTYLE_SERIF
Serif.
|
static int |
FONTSTYLE_SMALLCAP
Small cap.
|
static int |
FONTSTYLE_SYMBOLIC
Symbolic.
|
static int |
STDFONT_COURIER
Courier.
|
static int |
STDFONT_COURIER_B
Bold.
|
static int |
STDFONT_COURIER_BI
Bold italic.
|
static int |
STDFONT_COURIER_I
Italic.
|
static int |
STDFONT_HELVETICA
Helvetica.
|
static int |
STDFONT_HELVETICA_B
Bold.
|
static int |
STDFONT_HELVETICA_BI
Bold italic.
|
static int |
STDFONT_HELVETICA_I
Italic.
|
static int |
STDFONT_SYMBOL
Symbol.
|
static int |
STDFONT_TIMES
Times-Roman.
|
static int |
STDFONT_TIMES_B
Bold.
|
static int |
STDFONT_TIMES_BI
Bold italic.
|
static int |
STDFONT_TIMES_I
Italic.
|
static int |
STDFONT_ZAPFDINGBATS
ZapfDingbats.
|
Modifier and Type | Method and Description |
---|---|
static Font |
create(java.lang.String fontName,
int fontStyles,
int weight,
int charset)
Create a
Font object with specified attributes. |
static Font |
createFromFile(FileHandler fontFile,
int faceIndex,
int charset)
Create a
Font object from a FileHandler object. |
static Font |
createStandard(int fontID)
Create a standard
Font object by the standard font ID. |
static Font.FontFace[] |
enumFaces(FileHandler fontFile)
Enumerate faces from a font file.
|
int |
getAscent()
Get the ascent value of the font.
|
Rect |
getCharBBox(char unicode)
Get the specific character bounding box of the font.
|
float |
getCharWidth(char unicode)
Get the specific character width of the font.
|
int |
getDescent()
Get the descent value of the font.
|
java.lang.String |
getFaceName()
Retrieve face name of a font.
|
long |
getHandle()
Get the font Handle.
|
boolean |
isBold()
Judge whether a font object is bold or not.
|
boolean |
isItalic()
Judge whether a
Font object is italic or not. |
static void |
release(Font font)
Release a
Font object. |
public static final int FONTSTYLE_FIXEDPITCH
public static final int FONTSTYLE_SERIF
public static final int FONTSTYLE_SYMBOLIC
public static final int FONTSTYLE_SCRIPT
public static final int FONTSTYLE_NONSYMBOLIC
public static final int FONTSTYLE_ITALIC
public static final int FONTSTYLE_ALLCAP
public static final int FONTSTYLE_SMALLCAP
public static final int FONTSTYLE_BOLD
public static final int CHARSET_ANSI
public static final int CHARSET_DEFAULT
public static final int CHARSET_SYMBOL
public static final int CHARSET_SHIFTJIS
public static final int CHARSET_HANGEUL
public static final int CHARSET_GB2312
public static final int CHARSET_CHINESEBIG5
public static final int CHARSET_THAI
public static final int CHARSET_EASTEUROPE
public static final int CHARSET_RUSSIAN
public static final int CHARSET_GREEK
public static final int CHARSET_TURKISH
public static final int CHARSET_HEBREW
public static final int CHARSET_ARABIC
public static final int CHARSET_BALTIC
public static final int STDFONT_COURIER
public static final int STDFONT_COURIER_B
public static final int STDFONT_COURIER_BI
public static final int STDFONT_COURIER_I
public static final int STDFONT_HELVETICA
public static final int STDFONT_HELVETICA_B
public static final int STDFONT_HELVETICA_BI
public static final int STDFONT_HELVETICA_I
public static final int STDFONT_TIMES
public static final int STDFONT_TIMES_B
public static final int STDFONT_TIMES_BI
public static final int STDFONT_TIMES_I
public static final int STDFONT_SYMBOL
public static final int STDFONT_ZAPFDINGBATS
public long getHandle()
public int getAscent() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getDescent() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public Rect getCharBBox(char unicode) throws PDFException
unicode
- The character unicode value.Rect
object that receives the character bounding box.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Rect
public float getCharWidth(char unicode) throws PDFException
unicode
- The character unicode value.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isItalic() throws PDFException
Font
object is italic or not.true
if the font is italic, false
for else.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isBold() throws PDFException
true
if the font is bold, false
for else.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getFaceName() throws PDFException
String
object that indicates face name of the font.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public static Font create(java.lang.String fontName, int fontStyles, int weight, int charset) throws PDFException
Font
object with specified attributes.fontName
- A String
object specifies the typeface name of the font.fontStyles
- The styles of the font, It can be one or a combination of these constants
FONTSTYLE_XXX
.weight
- Original font weight, 0 if unspecified.charset
- The charset of the font. It should be one of these constants
CHARSET_XXX
.Font
objectPDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Font
public static Font createStandard(int fontID) throws PDFException
Font
object by the standard font ID.fontID
- ID of standard font defined above. It should be one of these
constants STDFONT_XXX
.Font
object.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Font
public static Font createFromFile(FileHandler fontFile, int faceIndex, int charset) throws PDFException
Font
object from a FileHandler
object.fontFile
- A FileHandler
object specifies the input font
file source.faceIndex
- The zero-based face index, ranging from [0, face_count), the
face_count is the length of FontFace array which
is returned by calling enumFaces(FileHandler)
interface.
charset
- The charset of the font. It should be one of these constants
CHARSET_XXX
.Font
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Font
,
FileHandler
public static Font.FontFace[] enumFaces(FileHandler fontFile) throws PDFException
fontFile
- A FileHandler
object specifies the input font file source.FontFace
objects array that receives the faces of the font file.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public static void release(Font font) throws PDFException
Font
object.font
- A Font
object which is created by functions
create(String, int, int, int)
,
createStandard(int)
or
createFromFile(FileHandler, int, int)
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Font