Foxit PDF SDK
com.foxit.sdk.common.Font Class Reference
Inheritance diagram for com.foxit.sdk.common.Font:
com.foxit.sdk.common.Base

Public Member Functions

 Font (String name, int styles, int charset, int weight) throws com.foxit.sdk.PDFException
 Constructor, with given attribute.
More...
 
 Font (int font_id) throws com.foxit.sdk.PDFException
 Constructor, by a standard font ID.
More...
 
 Font (String font_file_path, int face_index, int charset) throws com.foxit.sdk.PDFException
 Constructor, from a font file.
More...
 
 Font (Font other)
 Constructor, with another font object.
More...
 
Font embed (PDFDoc document) throws com.foxit.sdk.PDFException
 Embed current font to the specified PDF document.
More...
 
int getAscent () throws com.foxit.sdk.PDFException
 Get the ascent value, in 1/1000 of em size (PDF units).
More...
 
String getBaseFontName (PDFDoc document) throws com.foxit.sdk.PDFException
 Get base font name.
More...
 
RectI getCharBBox (int unicode) throws com.foxit.sdk.PDFException
 Get the bounding box of a character specified by unicode.
More...
 
RectI getCharBBox (int unicode, PDFDoc document) throws com.foxit.sdk.PDFException
 Get the bounding box of a character that in document specified by unicode.
More...
 
float getCharWidth (int unicode) throws com.foxit.sdk.PDFException
 Get the width (in 1/1000 of em size (PDF units)) of a character specified by unicode.
More...
 
float getCharWidth (int unicode, PDFDoc document) throws com.foxit.sdk.PDFException
 Get the width (in 1/1000 of em size (PDF units)) of a character that in document specified by unicode.
More...
 
int getCIDCharset (PDFDoc document) throws com.foxit.sdk.PDFException
 Get CID font charset.
More...
 
int getDescent () throws com.foxit.sdk.PDFException
 Get the descent value, in 1/1000 of em size (PDF units).
More...
 
String getFamilyName () throws com.foxit.sdk.PDFException
 Retrieve the famliy name.
More...
 
int getFontType (PDFDoc document) throws com.foxit.sdk.PDFException
 Get font type.
More...
 
String getName () throws com.foxit.sdk.PDFException
 Retrieve the postscript name.
More...
 
int getStandard14Font (PDFDoc document) throws com.foxit.sdk.PDFException
 Get standard font ID.
More...
 
int getStyles (PDFDoc document) throws com.foxit.sdk.PDFException
 Get font styles.
More...
 
boolean isBold () throws com.foxit.sdk.PDFException
 Judge whether current font is bold or not.
More...
 
boolean isEmbedded (PDFDoc document) throws com.foxit.sdk.PDFException
 Judge whether current font is embedded in a specified PDF document or not.
More...
 
boolean isEmpty ()
 Check whether current object is empty or not.
More...
 
boolean isItalic () throws com.foxit.sdk.PDFException
 Judge whether current font object is italic or not.
More...
 
boolean isStandardFont (PDFDoc document) throws com.foxit.sdk.PDFException
 Check whether current font is a standard font.
More...
 
boolean isSupportEmbedded (PDFDoc document) throws com.foxit.sdk.PDFException
 Check whether current font is supported to be embedded to the specified PDF document or not.
More...
 

Static Public Attributes

static final int e_CharsetANSI = 0
 Font charset: ANSI (United States, Western Europe).

 
static final int e_CharsetArabic = 178
 Font charset: Arabic.

 
static final int e_CharsetBaltic = 186
 Font charset: Baltic.

 
static final int e_CharsetChineseBig5 = 136
 Font charset: Traditional Chinese.

 
static final int e_CharsetDefault = 1
 Font charset: System default, for unknown or mapping purpose.

 
static final int e_CharsetEastEurope = 238
 Font charset: Eastern European.

 
static final int e_CharsetGB2312 = 134
 Font charset: Simplified Chinese.

 
static final int e_CharsetGreek = 161
 Font charset: Greek.

 
static final int e_CharsetHangeul = 129
 Font charset: Korean (Wansung).

 
static final int e_CharsetHebrew = 177
 Font charset: Hebrew.

 
static final int e_CharsetRussian = 204
 Font charset: Russian.

 
static final int e_CharsetShift_JIS = 128
 Font charset: Japanese (Shift-JIS).

 
static final int e_CharsetSymbol = 2
 Font charset: Standard symbols.

 
static final int e_CharsetThai = 222
 Font charset: Thai.

 
static final int e_CharsetTurkish = 162
 Font charset: Turkish.

 
static final int e_CIDCharsetCNS1 = 2
 CID Font charset: Adobe-CNS1.

 
static final int e_CIDCharsetGB1 = 1
 CID Font charset: Adobe-GB1.

 
static final int e_CIDCharsetJAPAN1 = 3
 CID Font charset: Adobe-Japan1.

 
static final int e_CIDCharsetKOREA1 = 4
 CID Font charset: Adobe-Korea1.

 
static final int e_CIDCharsetUNICODE = 5
 CID Font charset: Unicode.

 
static final int e_CIDCharsetUnknown = 0
 CID Font charset: Unknown.

 
static final int e_FontTypeCIDFont = 4
 Font type: CID font.

 
static final int e_FontTypeTrueType = 2
 Font type: TrueType.

 
static final int e_FontTypeType1 = 1
 Font type: Type1.

 
static final int e_FontTypeType3 = 3
 Font type: Type3.

 
static final int e_StdIDCourier = 0
 Standard font: Courier.

 
static final int e_StdIDCourierB = 1
 Standard font: Courier-Bold.

 
static final int e_StdIDCourierBI = 2
 Standard font: Courier-BoldOblique, Bold italic.

 
static final int e_StdIDCourierI = 3
 Standard font: Courier-Oblique, Italic.

 
static final int e_StdIDHelvetica = 4
 Standard font: Helvetica.

 
static final int e_StdIDHelveticaB = 5
 Standard font: Helvetica-Bold.

 
static final int e_StdIDHelveticaBI = 6
 Standard font: Helvetica-BoldOblique, Bold italic.

 
static final int e_StdIDHelveticaI = 7
 Standard font: Helvetica-Oblique, Italic.

 
static final int e_StdIDSymbol = 12
 Standard font: Symbol.

 
static final int e_StdIDTimes = 8
 Standard font: Times-Roman.

 
static final int e_StdIDTimesB = 9
 Standard font: Times-Bold.

 
static final int e_StdIDTimesBI = 10
 Standard font: Times-BoldItalic.

 
static final int e_StdIDTimesI = 11
 Standard font: Times-Italic.

 
static final int e_StdIDZapfDingbats = 13
 Standard font: ZapfDingbats.

 
static final int e_StyleAllCap = 0x10000
 Font style: all cap.

 
static final int e_StyleFixedPitch = 0x0001
 Font style: fixed pitch.

 
static final int e_StyleItalic = 0x0040
 Font style: italic.

 
static final int e_StyleNonSymbolic = 0x0020
 Font style: non-symbolic.

 
static final int e_StylesBold = 0x40000
 Font style: force bold.

 
static final int e_StyleScript = 0x0008
 Font style: script.

 
static final int e_StyleSerif = 0x0002
 Font style: serif.

 
static final int e_StylesSmallCap = 0x20000
 Font style: small cap.

 
static final int e_StyleSymbolic = 0x0004
 Font style: symbolic.

 

Detailed Description

In PDF document, font is used for drawing text in PDF page.
This class represents font used in Foxit PDF SDK. This class offers different constructor for user to construct a new font object, by specified parameters, by standard font ID, or from a font file path. A font object can also be retrieved directly from other object (such as free text annotation, a text graphics object, etc) in a PDF document. This class also offers some functions to get some basic information from a font.

Constructor & Destructor Documentation

◆ Font() [1/4]

com.foxit.sdk.common.Font.Font ( String  name,
int  styles,
int  charset,
int  weight 
) throws com.foxit.sdk.PDFException

Constructor, with given attribute.

This function is to construct font based on system fonts.

Parameters
[in]nameThe PostScript name of the font to be created.
[in]stylesFont styles. Please refer to values starting from com.foxit.sdk.common.Font.e_StyleFixedPitch and this can be one or a combination of these values.
[in]charsetThe charset of the font to be created. Please refer to values starting from com.foxit.sdk.common.Font.e_CharsetANSI and this should be one of these values.
[in]weightOriginal font weight. 0 means unspecified.

◆ Font() [2/4]

com.foxit.sdk.common.Font.Font ( int  font_id) throws com.foxit.sdk.PDFException

Constructor, by a standard font ID.

Parameters
[in]font_idStandard font ID of the font to be created. Please refer to values starting from com.foxit.sdk.common.Font.e_StdIDCourier and this should be one of these values.

◆ Font() [3/4]

com.foxit.sdk.common.Font.Font ( String  font_file_path,
int  face_index,
int  charset 
) throws com.foxit.sdk.PDFException

Constructor, from a font file.

Parameters
[in]font_file_pathA full path to an existing font file.
[in]face_indexThe zero-based face index. Valid range: from 0 to (face_count-1). Please call the system functions to get the face_count.
[in]charsetThe charset of the font to be created. Please refer to values starting from com.foxit.sdk.common.Font.e_CharsetANSI and this should be one of these values.

◆ Font() [4/4]

com.foxit.sdk.common.Font.Font ( Font  other)

Constructor, with another font object.

Parameters
[in]otherAnother font object.

Member Function Documentation

◆ embed()

Font com.foxit.sdk.common.Font.embed ( PDFDoc  document) throws com.foxit.sdk.PDFException

Embed current font to the specified PDF document.

Parameters
[in]documentA valid PDF document object.
Returns
The embedded font.

◆ getAscent()

int com.foxit.sdk.common.Font.getAscent ( ) throws com.foxit.sdk.PDFException

Get the ascent value, in 1/1000 of em size (PDF units).

Returns
The ascent value, in 1/1000 of em size (PDF units).

◆ getBaseFontName()

String com.foxit.sdk.common.Font.getBaseFontName ( PDFDoc  document) throws com.foxit.sdk.PDFException

Get base font name.

Parameters
[in]documentA valid PDF document object.
Returns
Base font name.

◆ getCharBBox() [1/2]

RectI com.foxit.sdk.common.Font.getCharBBox ( int  unicode) throws com.foxit.sdk.PDFException

Get the bounding box of a character specified by unicode.

Parameters
[in]unicodeA character unicode value.
Returns
The character bounding box.

◆ getCharBBox() [2/2]

RectI com.foxit.sdk.common.Font.getCharBBox ( int  unicode,
PDFDoc  document 
) throws com.foxit.sdk.PDFException

Get the bounding box of a character that in document specified by unicode.

Parameters
[in]unicodeA character unicode value.
[in]documentA valid PDF document object.
Returns
The character bounding box.

◆ getCharWidth() [1/2]

float com.foxit.sdk.common.Font.getCharWidth ( int  unicode) throws com.foxit.sdk.PDFException

Get the width (in 1/1000 of em size (PDF units)) of a character specified by unicode.

Parameters
[in]unicodeA character unicode value.
Returns
The character width, in 1/1000 of em size (PDF units).

◆ getCharWidth() [2/2]

float com.foxit.sdk.common.Font.getCharWidth ( int  unicode,
PDFDoc  document 
) throws com.foxit.sdk.PDFException

Get the width (in 1/1000 of em size (PDF units)) of a character that in document specified by unicode.

Parameters
[in]unicodeA character unicode value.
[in]documentA valid PDF document object.
Returns
The character width, in 1/1000 of em size (PDF units).

◆ getCIDCharset()

int com.foxit.sdk.common.Font.getCIDCharset ( PDFDoc  document) throws com.foxit.sdk.PDFException

Get CID font charset.

Applicable for CID based fonts. For rest type of font, exception com.foxit.sdk.common.Constants.e_ErrUnsupported will be thrown.

Parameters
[in]documentA valid PDF document object.
Returns
Font charset. Please refer to values starting from com.foxit.sdk.common.Font.e_CIDCharsetUnknown and this would be one of these values.

◆ getDescent()

int com.foxit.sdk.common.Font.getDescent ( ) throws com.foxit.sdk.PDFException

Get the descent value, in 1/1000 of em size (PDF units).

Returns
The descent value, in 1/1000 of em size (PDF units).

◆ getFamilyName()

String com.foxit.sdk.common.Font.getFamilyName ( ) throws com.foxit.sdk.PDFException

Retrieve the famliy name.

Returns
The famliy name.

◆ getFontType()

int com.foxit.sdk.common.Font.getFontType ( PDFDoc  document) throws com.foxit.sdk.PDFException

Get font type.

Parameters
[in]documentA valid PDF document object.
Returns
Font type. Please refer to values starting from com.foxit.sdk.common.Font.e_FontTypeType1 and this would be one of these values.

◆ getName()

String com.foxit.sdk.common.Font.getName ( ) throws com.foxit.sdk.PDFException

Retrieve the postscript name.

Returns
The postscript name.

◆ getStandard14Font()

int com.foxit.sdk.common.Font.getStandard14Font ( PDFDoc  document) throws com.foxit.sdk.PDFException

Get standard font ID.

Applicable for standard fonts. For rest type of font, exception com.foxit.sdk.common.Constants.e_ErrUnsupported will be thrown.

Parameters
[in]documentA valid PDF document object.
Returns
Standard font ID. Please refer to values starting from com.foxit.sdk.common.Font.e_StdIDCourier and this would be one of these values.

◆ getStyles()

int com.foxit.sdk.common.Font.getStyles ( PDFDoc  document) throws com.foxit.sdk.PDFException

Get font styles.

Parameters
[in]documentA valid PDF document object.
Returns
Font styles. Please refer to values starting from com.foxit.sdk.common.Font.e_StyleFixedPitch and this would be one or a combination of these values.

◆ isBold()

boolean com.foxit.sdk.common.Font.isBold ( ) throws com.foxit.sdk.PDFException

Judge whether current font is bold or not.

Returns
true means current font is bold, while false means not.

◆ isEmbedded()

boolean com.foxit.sdk.common.Font.isEmbedded ( PDFDoc  document) throws com.foxit.sdk.PDFException

Judge whether current font is embedded in a specified PDF document or not.

Parameters
[in]documentA valid PDF document object.
Returns
true means the font is embedded in the specified PDF document, while false means not.

◆ isEmpty()

boolean com.foxit.sdk.common.Font.isEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ isItalic()

boolean com.foxit.sdk.common.Font.isItalic ( ) throws com.foxit.sdk.PDFException

Judge whether current font object is italic or not.

Returns
true means current font is italic, while false means not.

◆ isStandardFont()

boolean com.foxit.sdk.common.Font.isStandardFont ( PDFDoc  document) throws com.foxit.sdk.PDFException

Check whether current font is a standard font.

Parameters
[in]documentA valid PDF document object.
Returns
true means current font is a standard font, while false means not.

◆ isSupportEmbedded()

boolean com.foxit.sdk.common.Font.isSupportEmbedded ( PDFDoc  document) throws com.foxit.sdk.PDFException

Check whether current font is supported to be embedded to the specified PDF document or not.

Parameters
[in]documentA valid PDF document object.
Returns
true means current font is supported to be embedded to the specified PDF document, while false means not.