Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
FSDK.Font Class Reference

## Public Member Functions
| AddUnicodes (document, unicode_array)
| Add unicodes to current embedded font. More...
| constructor (font_file_path, face_index, charset)
| Constructor, from a font file. More...
| constructor (font_id)
| Constructor, by a standard font ID. More...
| constructor (name, styles, charset, weight)
| Constructor, with given attribute. More...
| Embed (document, is_add_all_unicodes)
| Embed current font to the specified PDF document. More...
| GetAscent ()
| Get the ascent value, in 1/1000 of em size (PDF units). More...
| GetBaseFontName (document)
| Get base font name. More...
| GetCharBBox (unicode)
| Get the bounding box of a character specified by unicode. More...
| GetCharBBox (unicode, document)
| Get the bounding box of a character(specified by unicode) in a PDF document. More...
| GetCharWidth (unicode)
| Get the width (in 1/1000 of em size (PDF units)) of a character specified by unicode. More...
| GetCharWidth (unicode, document)
| Get the width (in 1/1000 of em size, as PDF units) of a character (specified by unicode) in a PDF document. More...
| GetCIDCharset (document)
| Get CID font charset. More...
| GetDescent ()
| Get the descent value, in 1/1000 of em size (PDF units). More...
| GetEncoding (document)
| Get the current font encoding. More...
| GetFamilyName ()
| Retrieve the famliy name. More...
| GetFontType (document)
| Get font type. More...
| GetName ()
| Retrieve the postscript name. More...
| GetStandard14Font (document)
| Get standard font ID. More...
| GetStyles (document)
| Get font styles. More...
| IsBold ()
| Judge whether current font is bold or not. More...
| IsCharSupported (unicode, document)
| Check whether the character is supported by current font. More...
| IsEmbedded (document)
| Judge whether current font is embedded in a specified PDF document or not. More...
| IsEmpty ()
| Check whether current object is empty or not. More...
| IsItalic ()
| Judge whether current font object is italic or not. More...
| IsStandardFont (document)
| Check whether current font is a standard font. More...
| IsSupportEmbedded (document)
| Check whether current font is supported to be embedded to the specified PDF document or not. More...
| IsVertWriting (document)
| Check whether current font is vertical writing. More...
| SetEncoding (document, value)
| Set the current font encoding. More...

## Static Public Attributes
static | e_CharsetANSI
| Enumeration for font charset. More...
static | e_CharsetArabic
| Font charset: Arabic.
static | e_CharsetBaltic
| Font charset: Baltic.
static | e_CharsetChineseBig5
| Font charset: Traditional Chinese.
static | e_CharsetDefault
| Font charset: System default, for unknown or mapping purpose.
static | e_CharsetEastEurope
| Font charset: Eastern European.
static | e_CharsetGB2312
| Font charset: Simplified Chinese.
static | e_CharsetGreek
| Font charset: Greek.
static | e_CharsetHangeul
| Font charset: Korean (Wansung).
static | e_CharsetHebrew
| Font charset: Hebrew.
static | e_CharsetRussian
| Font charset: Russian.
static | e_CharsetShift_JIS
| Font charset: Japanese (Shift-JIS).
static | e_CharsetSymbol
| Font charset: Standard symbols.
static | e_CharsetThai
| Font charset: Thai.
static | e_CharsetTurkish
| Font charset: Turkish.
static | e_CIDCharsetCNS1
| CID Font charset: Adobe-CNS1.
static | e_CIDCharsetGB1
| CID Font charset: Adobe-GB1.
static | e_CIDCharsetJAPAN1
| CID Font charset: Adobe-Japan1.
static | e_CIDCharsetKOREA1
| CID Font charset: Adobe-Korea1.
static | e_CIDCharsetUNICODE
| CID Font charset: Unicode.
static | e_CIDCharsetUnknown
| Enumeration for CID font charset. More...
static | e_FontTypeCIDFont
| Font type: CID font.
static | e_FontTypeTrueType
| Font type: TrueType.
static | e_FontTypeType1
| Enumeration for font type. More...
static | e_FontTypeType3
| Font type: Type3.
static | e_StdIDCourier
| Enumeration for standard font ID. More...
static | e_StdIDCourierB
| Standard font: Courier-Bold.
static | e_StdIDCourierBI
| Standard font: Courier-BoldOblique, Bold italic.
static | e_StdIDCourierI
| Standard font: Courier-Oblique, Italic.
static | e_StdIDHelvetica
| Standard font: Helvetica.
static | e_StdIDHelveticaB
| Standard font: Helvetica-Bold.
static | e_StdIDHelveticaBI
| Standard font: Helvetica-BoldOblique, Bold italic.
static | e_StdIDHelveticaI
| Standard font: Helvetica-Oblique, Italic.
static | e_StdIDSymbol
| Standard font: Symbol.
static | e_StdIDTimes
| Standard font: Times-Roman.
static | e_StdIDTimesB
| Standard font: Times-Bold.
static | e_StdIDTimesBI
| Standard font: Times-BoldItalic.
static | e_StdIDTimesI
| Standard font: Times-Italic.
static | e_StdIDZapfDingbats
| Standard font: ZapfDingbats.
static | e_StyleAllCap
| Font style: all cap.
static | e_StyleFixedPitch
| Enumeration for font styles. More...
static | e_StyleItalic
| Font style: italic.
static | e_StyleNonSymbolic
| Font style: non-symbolic.
static | e_StylesBold
| Font style: force bold.
static | e_StyleScript
| Font style: script.
static | e_StyleSerif
| Font style: serif.
static | e_StylesSmallCap
| Font style: small cap.
static | e_StyleSymbolic
| 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.

## Member Function Documentation

## ◆ AddUnicodes()

FSDK.Font.AddUnicodes | ( | document | ,
|  | unicode_array |
| ) |  |

Add unicodes to current embedded font.

This function only support newly embedded font.

Parameters

  [in] | document | A valid PDF document object.
  [in] | unicode_array | The unicode array to be embedded.

Returns
  The result unicode array that is embedded to font successfully.

## ◆ constructor() [1/3]

FSDK.Font.constructor | ( | font_file_path | ,
|  | face_index | ,
|  | charset |
| ) |  |

Constructor, from a font file.

Parameters

  [in] | font_file_path | A full path to an existing font file.
  [in] | face_index | The zero-based face index. Valid range: from 0 to (face_count-1). Please call the system functions to get the face_count.
  [in] | charset | The charset of the font to be created. Please refer to values starting from FSDK.Font.e_CharsetANSI and this should be one of these values.

## ◆ constructor() [2/3]

FSDK.Font.constructor | ( | font_id |  | ) |

Constructor, by a standard font ID.

Parameters

  [in] | font_id | Standard font ID of the font to be created. Please refer to values starting from FSDK.Font.e_StdIDCourier and this should be one of these values.

## ◆ constructor() [3/3]

FSDK.Font.constructor | ( | name | ,
|  | styles | ,
|  | charset | ,
|  | weight |
| ) |  |

Constructor, with given attribute.

This function is to construct font based on system fonts.

Parameters

  [in] | name | The PostScript name of the font to be created.
  [in] | styles | Font styles. Please refer to values starting from FSDK.Font.e_StyleFixedPitch and this can be one or a combination of these values.
  [in] | charset | The charset of the font to be created. Please refer to values starting from FSDK.Font.e_CharsetANSI and this should be one of these values.
  [in] | weight | Original font weight. 0 means unspecified.

## ◆ Embed()

FSDK.Font.Embed | ( | document | ,
|  | is_add_all_unicodes |
| ) |  |

Embed current font to the specified PDF document.

Parameters

  [in] | document | A valid PDF document object.
  [in] | is_add_all_unicodes | Whether 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 FSDK.Font.AddUnicodes.

Returns
  The embedded font.

## ◆ GetAscent()

FSDK.Font.GetAscent | ( |  | ) |

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

FSDK.Font.GetBaseFontName | ( | document |  | ) |

Get base font name.

Parameters

  [in] | document | A valid PDF document object.

Returns
  Base font name.

## ◆ GetCharBBox() [1/2]

FSDK.Font.GetCharBBox | ( | unicode |  | ) |

Get the bounding box of a character specified by unicode.

Parameters

  [in] | unicode | A character unicode value.

Returns
  The character bounding box.

## ◆ GetCharBBox() [2/2]

FSDK.Font.GetCharBBox | ( | unicode | ,
|  | document |
| ) |  |

Get the bounding box of a character(specified by unicode) in a PDF document.

Parameters

  [in] | unicode | A character unicode value.
  [in] | document | A valid PDF document object.

Returns
  The character bounding box.

## ◆ GetCharWidth() [1/2]

FSDK.Font.GetCharWidth | ( | unicode |  | ) |

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

Parameters

  [in] | unicode | A character unicode value.

Returns
  The character width, in 1/1000 of em size (PDF units).

## ◆ GetCharWidth() [2/2]

FSDK.Font.GetCharWidth | ( | unicode | ,
|  | document |
| ) |  |

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

Parameters

  [in] | unicode | A character unicode value.
  [in] | document | A valid PDF document object.

Returns
  The character width, in 1/1000 of em size (PDF units).

## ◆ GetCIDCharset()

FSDK.Font.GetCIDCharset | ( | document |  | ) |

Get CID font charset.

Applicable for CID based fonts. For rest type of font, exception FSDK.e_ErrUnsupported will be thrown.

Parameters

  [in] | document | A valid PDF document object.

Returns
  Font charset. Please refer to values starting from FSDK.Font.e_CIDCharsetUnknown and this would be one of these values.

## ◆ GetDescent()

FSDK.Font.GetDescent | ( |  | ) |

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

FSDK.Font.GetEncoding | ( | document |  | ) |

Get the current font encoding.

Parameters

  [in] | document | A 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()

FSDK.Font.GetFamilyName | ( |  | ) |

Retrieve the famliy name.

Returns
  The famliy name.

## ◆ GetFontType()

FSDK.Font.GetFontType | ( | document |  | ) |

Get font type.

Parameters

  [in] | document | A valid PDF document object.

Returns
  Font type. Please refer to values starting from FSDK.Font.e_FontTypeType1 and this would be one of these values.

## ◆ GetName()

FSDK.Font.GetName | ( |  | ) |

Retrieve the postscript name.

Returns
  The postscript name.

## ◆ GetStandard14Font()

FSDK.Font.GetStandard14Font | ( | document |  | ) |

Get standard font ID.

Applicable for standard fonts. For rest type of font, exception FSDK.e_ErrUnsupported will be thrown.

Parameters

  [in] | document | A valid PDF document object.

Returns
  Standard font ID. Please refer to values starting from FSDK.Font.e_StdIDCourier and this would be one of these values.

## ◆ GetStyles()

FSDK.Font.GetStyles | ( | document |  | ) |

Get font styles.

Parameters

  [in] | document | A valid PDF document object.

Returns
  Font styles. Please refer to values starting from FSDK.Font.e_StyleFixedPitch and this would be one or a combination of these values.

## ◆ IsBold()

FSDK.Font.IsBold | ( |  | ) |

Judge whether current font is bold or not.

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

## ◆ IsCharSupported()

FSDK.Font.IsCharSupported | ( | unicode | ,
|  | document |
| ) |  |

Check whether the character is supported by current font.

Parameters

  [in] | unicode | A character unicode value.
  [in] | document | A PDF document object. If this font not embedded in the document, this parameter can be an empty object.

Returns
  true means the character is supported in its font, while false means not.

## ◆ IsEmbedded()

FSDK.Font.IsEmbedded | ( | document |  | ) |

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

Parameters

  [in] | document | A valid PDF document object.

Returns
  true means the font is embedded in the specified PDF document, while false means not.

## ◆ IsEmpty()

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

FSDK.Font.IsItalic | ( |  | ) |

Judge whether current font object is italic or not.

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

## ◆ IsStandardFont()

FSDK.Font.IsStandardFont | ( | document |  | ) |

Check whether current font is a standard font.

Parameters

  [in] | document | A valid PDF document object.

Returns
  true means current font is a standard font, while false means not.

## ◆ IsSupportEmbedded()

FSDK.Font.IsSupportEmbedded | ( | document |  | ) |

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

Parameters

  [in] | document | A valid PDF document object.

Returns
  true means current font is supported to be embedded to the specified PDF document, while false means not.

## ◆ IsVertWriting()

FSDK.Font.IsVertWriting | ( | document |  | ) |

Check whether current font is vertical writing.

Parameters

  [in] | document | A valid PDF document object.

Returns
  true means current font is vertical writing, while false means current font is not vertical writing.

## ◆ SetEncoding()

FSDK.Font.SetEncoding | ( | document | ,
|  | value |
| ) |  |

Set the current font encoding.

Parameters

  [in] | document | A valid PDF document object.
  [in] | value | The 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.

## Member Data Documentation

## ◆ e_CharsetANSI

FSDK.Font.e_CharsetANSI
| static

Enumeration for font charset.

Values of this enumeration should be used alone.

Font charset: ANSI (United States, Western Europe).

## ◆ e_CIDCharsetUnknown

FSDK.Font.e_CIDCharsetUnknown
| static

Enumeration for CID font charset.

Values of this enumeration should be used alone.

CID Font charset: Unknown.

## ◆ e_FontTypeType1

FSDK.Font.e_FontTypeType1
| static

Enumeration for font type.

Values of this enumeration can be used alone .

Font type: Type1.

## ◆ e_StdIDCourier

FSDK.Font.e_StdIDCourier
| static

Enumeration for standard font ID.

Values of this enumeration should be used alone.

Standard font: Courier.

## ◆ e_StyleFixedPitch

FSDK.Font.e_StyleFixedPitch
| static

Enumeration for font styles.

Values of this enumeration can be used alone or in combination.

Font style: fixed pitch.