Foxit PDF RDK

Public Member Functions | Static Public Attributes | List of all members
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...
| 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()

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]

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 Font.e_CharsetANSI and this should be one of these values.

## ◆ constructor() [2/3]

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 Font.e_StdIDCourier and this should be one of these values.

## ◆ constructor() [3/3]

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 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 Font.e_CharsetANSI and this should be one of these values.
  [in] | weight | Original font weight. 0 means unspecified.

## ◆ Embed()

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 Font.AddUnicodes.

Returns
  The embedded font.

## ◆ GetAscent()

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

Font.GetBaseFontName | ( | document |  | ) |

Get base font name.

Parameters

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

Returns
  Base font name.

## ◆ GetCharBBox() [1/2]

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]

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]

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]

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

Font.GetCIDCharset | ( | document |  | ) |

Get CID font charset.

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

Parameters

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

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

## ◆ GetDescent()

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

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

Font.GetFamilyName | ( |  | ) |

Retrieve the famliy name.

Returns
  The famliy name.

## ◆ GetFontType()

Font.GetFontType | ( | document |  | ) |

Get font type.

Parameters

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

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

## ◆ GetName()

Font.GetName | ( |  | ) |

Retrieve the postscript name.

Returns
  The postscript name.

## ◆ GetStandard14Font()

Font.GetStandard14Font | ( | document |  | ) |

Get standard font ID.

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

Parameters

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

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

## ◆ GetStyles()

Font.GetStyles | ( | document |  | ) |

Get font styles.

Parameters

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

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

## ◆ IsBold()

Font.IsBold | ( |  | ) |

Judge whether current font is bold or not.

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

## ◆ IsEmbedded()

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

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

Font.IsItalic | ( |  | ) |

Judge whether current font object is italic or not.

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

## ◆ IsStandardFont()

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

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

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

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

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

Font.e_CIDCharsetUnknown
| static

Enumeration for CID font charset.

Values of this enumeration should be used alone.

CID Font charset: Unknown.

## ◆ e_FontTypeType1

Font.e_FontTypeType1
| static

Enumeration for font type.

Values of this enumeration can be used alone .

Font type: Type1.

## ◆ e_StdIDCourier

Font.e_StdIDCourier
| static

Enumeration for standard font ID.

Values of this enumeration should be used alone.

Standard font: Courier.

## ◆ e_StyleFixedPitch

Font.e_StyleFixedPitch
| static

Enumeration for font styles.

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

Font style: fixed pitch.