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 (Font other)
 Constructor, with another font object.
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 (String name, int styles, int charset, int weight) throws com.foxit.sdk.PDFException
 Constructor, with given attribute.
More...
 
UInt32Array addUnicodes (PDFDoc document, UInt32Array unicode_array) throws com.foxit.sdk.PDFException
 Add unicodes to current embedded font.
More...
 
synchronized void delete ()
 Clean up related resources immediately. More...
 
Font embed (PDFDoc document, boolean is_add_all_unicodes) 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(specified by unicode) in a PDF document.
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, as PDF units) of a character (specified by unicode) in a PDF document.
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 getEncoding (PDFDoc document) throws com.foxit.sdk.PDFException
 Get the current font encoding.
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...
 
boolean isVertWriting (PDFDoc document) throws com.foxit.sdk.PDFException
 Check whether current font is vertical writing.
More...
 
boolean setEncoding (PDFDoc document, String value) throws com.foxit.sdk.PDFException
 Set the current font encoding.
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

◆ addUnicodes()

UInt32Array com.foxit.sdk.common.Font.addUnicodes ( PDFDoc  document,
UInt32Array  unicode_array 
) throws com.foxit.sdk.PDFException

Add unicodes to current embedded font.

This function only support newly embedded font.

Parameters
[in]documentA valid PDF document object.
[in]unicode_arrayThe unicode array to be embedded.
Returns
The result unicode array that is embedded to font successfully.

◆ delete()

synchronized void com.foxit.sdk.common.Font.delete ( )

Clean up related resources immediately.

Returns
None.
Note
Once this function is called, current object cannot be used anymore.

Reimplemented from com.foxit.sdk.common.Base.

◆ embed()

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

Embed current font to the specified PDF document.

Parameters
[in]documentA valid PDF document object.
[in]is_add_all_unicodesWhether to add unicodes that are from 0x0 to 0xFFFF to current embedded font if no unicodes which are in document are added. true means embeded unicodes that are from 0x0 to 0xFFFF, while false means that just embeded one unicode. Default: true. Users can add unicodes via Font.addUnicodes .
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(specified by unicode) in a PDF document.

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, as PDF units) of a character (specified by unicode) in a PDF document.

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).

◆ getEncoding()

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

Get the current font encoding.

Parameters
[in]documentA valid PDF document object.
Returns
The value of font encoding, please refer to "TABLE 5.15 Predefined CJK CMap names" in <PDF reference 1.7> P442.

◆ 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.

◆ isVertWriting()

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

Check whether current font is vertical writing.

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

◆ setEncoding()

boolean com.foxit.sdk.common.Font.setEncoding ( PDFDoc  document,
String  value 
) throws com.foxit.sdk.PDFException

Set the current font encoding.

Parameters
[in]documentA valid PDF document object.
[in]valueThe font encoding to be set. For encoding values, please refer to
"TABLE 5.15 Predefined CJK CMap names" in <PDF reference 1.7> P442. This parameter should not be an empty string.
Returns
true means success, while false means failed.