Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
FoxitPDFSDKPython2.Font Class Reference
Inheritance diagram for FoxitPDFSDKPython2.Font:

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

## Static Public Attributes
| e_CharsetANSI = _fsdk.Font_e_CharsetANSI
| Font charset: ANSI (United States, Western Europe).
| e_CharsetArabic = _fsdk.Font_e_CharsetArabic
| Font charset: Arabic.
| e_CharsetBaltic = _fsdk.Font_e_CharsetBaltic
| Font charset: Baltic.
| e_CharsetChineseBig5 = _fsdk.Font_e_CharsetChineseBig5
| Font charset: Traditional Chinese.
| e_CharsetDefault = _fsdk.Font_e_CharsetDefault
| Font charset: System default, for unknown or mapping purpose.
| e_CharsetEastEurope = _fsdk.Font_e_CharsetEastEurope
| Font charset: Eastern European.
| e_CharsetGB2312 = _fsdk.Font_e_CharsetGB2312
| Font charset: Simplified Chinese.
| e_CharsetGreek = _fsdk.Font_e_CharsetGreek
| Font charset: Greek.
| e_CharsetHangeul = _fsdk.Font_e_CharsetHangeul
| Font charset: Korean (Wansung).
| e_CharsetHebrew = _fsdk.Font_e_CharsetHebrew
| Font charset: Hebrew.
| e_CharsetRussian = _fsdk.Font_e_CharsetRussian
| Font charset: Russian.
| e_CharsetShift_JIS = _fsdk.Font_e_CharsetShift_JIS
| Font charset: Japanese (Shift-JIS).
| e_CharsetSymbol = _fsdk.Font_e_CharsetSymbol
| Font charset: Standard symbols.
| e_CharsetThai = _fsdk.Font_e_CharsetThai
| Font charset: Thai.
| e_CharsetTurkish = _fsdk.Font_e_CharsetTurkish
| Font charset: Turkish.
| e_CIDCharsetCNS1 = _fsdk.Font_e_CIDCharsetCNS1
| CID Font charset: Adobe-CNS1.
| e_CIDCharsetGB1 = _fsdk.Font_e_CIDCharsetGB1
| CID Font charset: Adobe-GB1.
| e_CIDCharsetJAPAN1 = _fsdk.Font_e_CIDCharsetJAPAN1
| CID Font charset: Adobe-Japan1.
| e_CIDCharsetKOREA1 = _fsdk.Font_e_CIDCharsetKOREA1
| CID Font charset: Adobe-Korea1.
| e_CIDCharsetUNICODE = _fsdk.Font_e_CIDCharsetUNICODE
| CID Font charset: Unicode.
| e_CIDCharsetUnknown = _fsdk.Font_e_CIDCharsetUnknown
| CID Font charset: Unknown.
| e_FontTypeCIDFont = _fsdk.Font_e_FontTypeCIDFont
| Font type: CID font.
| e_FontTypeTrueType = _fsdk.Font_e_FontTypeTrueType
| Font type: TrueType.
| e_FontTypeType1 = _fsdk.Font_e_FontTypeType1
| Font type: Type1.
| e_FontTypeType3 = _fsdk.Font_e_FontTypeType3
| Font type: Type3.
| e_StdIDCourier = _fsdk.Font_e_StdIDCourier
| Standard font: Courier.
| e_StdIDCourierB = _fsdk.Font_e_StdIDCourierB
| Standard font: Courier-Bold.
| e_StdIDCourierBI = _fsdk.Font_e_StdIDCourierBI
| Standard font: Courier-BoldOblique, Bold italic.
| e_StdIDCourierI = _fsdk.Font_e_StdIDCourierI
| Standard font: Courier-Oblique, Italic.
| e_StdIDHelvetica = _fsdk.Font_e_StdIDHelvetica
| Standard font: Helvetica.
| e_StdIDHelveticaB = _fsdk.Font_e_StdIDHelveticaB
| Standard font: Helvetica-Bold.
| e_StdIDHelveticaBI = _fsdk.Font_e_StdIDHelveticaBI
| Standard font: Helvetica-BoldOblique, Bold italic.
| e_StdIDHelveticaI = _fsdk.Font_e_StdIDHelveticaI
| Standard font: Helvetica-Oblique, Italic.
| e_StdIDSymbol = _fsdk.Font_e_StdIDSymbol
| Standard font: Symbol.
| e_StdIDTimes = _fsdk.Font_e_StdIDTimes
| Standard font: Times-Roman.
| e_StdIDTimesB = _fsdk.Font_e_StdIDTimesB
| Standard font: Times-Bold.
| e_StdIDTimesBI = _fsdk.Font_e_StdIDTimesBI
| Standard font: Times-BoldItalic.
| e_StdIDTimesI = _fsdk.Font_e_StdIDTimesI
| Standard font: Times-Italic.
| e_StdIDZapfDingbats = _fsdk.Font_e_StdIDZapfDingbats
| Standard font: ZapfDingbats.
| e_StyleAllCap = _fsdk.Font_e_StyleAllCap
| Font style: all cap.
| e_StyleFixedPitch = _fsdk.Font_e_StyleFixedPitch
| Font style: fixed pitch.
| e_StyleItalic = _fsdk.Font_e_StyleItalic
| Font style: italic.
| e_StyleNonSymbolic = _fsdk.Font_e_StyleNonSymbolic
| Font style: non-symbolic.
| e_StylesBold = _fsdk.Font_e_StylesBold
| Font style: force bold.
| e_StyleScript = _fsdk.Font_e_StyleScript
| Font style: script.
| e_StyleSerif = _fsdk.Font_e_StyleSerif
| Font style: serif.
| e_StylesSmallCap = _fsdk.Font_e_StylesSmallCap
| Font style: small cap.
| e_StyleSymbolic = _fsdk.Font_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.

## Constructor & Destructor Documentation

## ◆ Font() [1/4]

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

## ◆ Font() [2/4]

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

## ◆ Font() [3/4]

def FoxitPDFSDKPython2.Font.Font | ( |  | other | ) |

Constructor, with another font object.

Parameters

  [in] | other | Another font object.

## ◆ Font() [4/4]

def FoxitPDFSDKPython2.Font.Font | ( |  | stream | ) |

Constructor, from a font stream by using FoxitPDFSDKPython2.StreamCallback .

Parameters

  [in] | stream | A FoxitPDFSDKPython2.StreamCallback object which is implemented by user to read the font file content.

## Member Function Documentation

## ◆ AddUnicodes()

def FoxitPDFSDKPython2.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.

## ◆ Embed()

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

Returns
  The embedded font.

## ◆ GetAscent()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.Font.GetBaseFontName | ( |  | document | ) |

Get base font name.

Parameters

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

Returns
  Base font name.

## ◆ GetCharBBox()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.Font.GetCIDCharset | ( |  | document | ) |

Get CID font charset.

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

Parameters

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

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

## ◆ GetDescent()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.Font.GetFamilyName | ( |  | ) |

Retrieve the famliy name.

Returns
  The famliy name.

## ◆ GetFontType()

def FoxitPDFSDKPython2.Font.GetFontType | ( |  | document | ) |

Get font type.

Parameters

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

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

## ◆ GetName()

def FoxitPDFSDKPython2.Font.GetName | ( |  | ) |

Retrieve the postscript name.

Returns
  The postscript name.

## ◆ GetStandard14Font()

def FoxitPDFSDKPython2.Font.GetStandard14Font | ( |  | document | ) |

Get standard font ID.

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

Parameters

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

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

## ◆ GetStyles()

def FoxitPDFSDKPython2.Font.GetStyles | ( |  | document | ) |

Get font styles.

Parameters

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

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

## ◆ IsBold()

def FoxitPDFSDKPython2.Font.IsBold | ( |  | ) |

Judge whether current font is bold or not.

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

## ◆ IsCharSupported()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.Font.IsItalic | ( |  | ) |

Judge whether current font object is italic or not.

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

## ◆ IsStandardFont()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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()

def FoxitPDFSDKPython2.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.