Foxit PDF SDK
fsdk.Font Class Reference

Public Member Functions

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)
 Get the bounding box of a character specified by unicode. More...
 
def GetCharBBox (unicode, document)
 Get the bounding box of a character(specified by unicode) in a PDF document. More...
 
def GetCharWidth (unicode)
 Get the width (in 1/1000 of em size (PDF units)) of a character specified by unicode. 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 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...
 

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

def fsdk.Font.AddUnicodes (   document,
  unicode_array 
)

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.

◆ Embed()

def fsdk.Font.Embed (   document,
  is_add_all_unicodes 
)

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 fsdk.Font.AddUnicodes .
Returns
The embedded font.

◆ GetAscent()

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

def fsdk.Font.GetBaseFontName (   document)

Get base font name.

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

◆ GetCharBBox() [1/2]

def fsdk.Font.GetCharBBox (   unicode)

Get the bounding box of a character specified by unicode.

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

◆ GetCharBBox() [2/2]

def fsdk.Font.GetCharBBox (   unicode,
  document 
)

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]

def fsdk.Font.GetCharWidth (   unicode)

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]

def 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]unicodeA character unicode value.
[in]documentA valid PDF document object.
Returns
The character width, in 1/1000 of em size (PDF units).

◆ GetCIDCharset()

def 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]documentA valid PDF document object.
Returns
Font charset. Please refer to values starting from fsdk.FontE_CIDCharsetUnknown and this would be one of these values.

◆ GetDescent()

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

def fsdk.Font.GetEncoding (   document)

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

def fsdk.Font.GetFamilyName ( )

Retrieve the famliy name.

Returns
The famliy name.

◆ GetFontType()

def fsdk.Font.GetFontType (   document)

Get font type.

Parameters
[in]documentA valid PDF document object.
Returns
Font type. Please refer to values starting from fsdk.FontE_FontTypeType1 and this would be one of these values.

◆ GetName()

def fsdk.Font.GetName ( )

Retrieve the postscript name.

Returns
The postscript name.

◆ GetStandard14Font()

def 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]documentA valid PDF document object.
Returns
Standard font ID. Please refer to values starting from fsdk.FontE_StdIDCourier and this would be one of these values.

◆ GetStyles()

def fsdk.Font.GetStyles (   document)

Get font styles.

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

◆ IsBold()

def fsdk.Font.IsBold ( )

Judge whether current font is bold or not.

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

◆ IsEmbedded()

def fsdk.Font.IsEmbedded (   document)

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

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

def fsdk.Font.IsItalic ( )

Judge whether current font object is italic or not.

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

◆ IsStandardFont()

def fsdk.Font.IsStandardFont (   document)

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

def fsdk.Font.IsSupportEmbedded (   document)

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

def fsdk.Font.IsVertWriting (   document)

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

def fsdk.Font.SetEncoding (   document,
  value 
)

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.