Foxit PDF SDK

Instance Methods | List of all members
FSFont Class Reference
Inheritance diagram for FSFont:

## Instance Methods
(FSUInt32Array *) | - addUnicodes:unicode_array:
| Add unicodes to current embedded font. More...
(FSFont *) | - embed:is_add_all_unicodes:
| Embed current font to the specified PDF document. More...
(int) | - getAscent
| Get the ascent value, in 1/1000 of em size (PDF units). More...
(NSString *) | - getBaseFontName:
| Get base font name. More...
(FSRectI *) | - getCharBBox:
| Get the bounding box of a character specified by unicode. More...
(FSRectI *) | - getCharBBoxWithPDFDoc:document:
| Get the bounding box of a character(specified by unicode) in a PDF document. More...
(float) | - getCharWidth:
| Get the width (in 1/1000 of em size (PDF units)) of a character specified by unicode. More...
(float) | - getCharWidthWithPDFDoc:document:
| Get the width (in 1/1000 of em size, as PDF units) of a character (specified by unicode) in a PDF document. More...
(FSFontCIDCharset) | - getCIDCharset:
| Get CID font charset. More...
(int) | - getDescent
| Get the descent value, in 1/1000 of em size (PDF units). More...
(NSString *) | - getEncoding:
| Get the current font encoding. More...
(NSString *) | - getFamilyName
| Retrieve the famliy name. More...
(FSFontFontTypes) | - getFontType:
| Get font type. More...
(NSString *) | - getName
| Retrieve the postscript name. More...
(FSFontStandardID) | - getStandard14Font:
| Get standard font ID. More...
(unsigned int) | - getStyles:
| Get font styles. More...
(id) | - initWithFont_file_path:face_index:charset:
| Constructor, from a font file. More...
(id) | - initWithFont_id:
| Constructor, by a standard font ID. More...
(id) | - initWithName:styles:charset:weight:
| Constructor, with given attribute. More...
(id) | - initWithOther:
| Constructor, with another font object. More...
(BOOL) | - isBold
| Judge whether current font is bold or not. More...
(BOOL) | - isCharSupported:document:
| Check whether the character is supported by current font. More...
(BOOL) | - isEmbedded:
| Judge whether current font is embedded in a specified PDF document or not. More...
(BOOL) | - isEmpty
| Check whether current object is empty or not. More...
(BOOL) | - isItalic
| Judge whether current font object is italic or not. More...
(BOOL) | - isStandardFont:
| Check whether current font is a standard font. More...
(BOOL) | - isSupportEmbedded:
| Check whether current font is supported to be embedded to the specified PDF document or not. More...
(BOOL) | - isVertWriting:
| Check whether current font is vertical writing. More...
(BOOL) | - setEncoding: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.

## Method Documentation

## ◆ addUnicodes:unicode_array:()

- (FSUInt32Array *) addUnicodes: |  | (FSPDFDoc*) | document
unicode_array: |  | (FSUInt32Array*) | 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:is_add_all_unicodes:()

- (FSFont *) embed: |  | (FSPDFDoc*) | document
is_add_all_unicodes: |  | (BOOL) | 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. YES means embeded unicodes that are from 0x0 to 0xFFFF, while NO means that just embeded one unicode. Default: YES. Users can add unicodes via FSFont::addUnicodes:unicode_array:.

Returns
  The embedded font.

## ◆ getAscent()

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

- (NSString *) getBaseFontName: |  | (FSPDFDoc*) | document |

Get base font name.

Parameters

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

Returns
  Base font name.

## ◆ getCharBBox:()

- (FSRectI *) getCharBBox: |  | (unsigned int) | unicode |

Get the bounding box of a character specified by unicode.

Parameters

  [in] | unicode | A character unicode value.

Returns
  The character bounding box.

## ◆ getCharBBoxWithPDFDoc:document:()

- (FSRectI *) getCharBBoxWithPDFDoc: |  | (unsigned int) | unicode
document: |  | (FSPDFDoc*) | 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:()

- (float) getCharWidth: |  | (unsigned int) | 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).

## ◆ getCharWidthWithPDFDoc:document:()

- (float) getCharWidthWithPDFDoc: |  | (unsigned int) | unicode
document: |  | (FSPDFDoc*) | 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:()

- (FSFontCIDCharset) getCIDCharset: |  | (FSPDFDoc*) | document |

Get CID font charset.

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

Parameters

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

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

## ◆ getDescent()

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

- (NSString *) getEncoding: |  | (FSPDFDoc*) | 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()

- (NSString *) getFamilyName |  |  |

Retrieve the famliy name.

Returns
  The famliy name.

## ◆ getFontType:()

- (FSFontFontTypes) getFontType: |  | (FSPDFDoc*) | document |

Get font type.

Parameters

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

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

## ◆ getName()

- (NSString *) getName |  |  |

Retrieve the postscript name.

Returns
  The postscript name.

## ◆ getStandard14Font:()

- (FSFontStandardID) getStandard14Font: |  | (FSPDFDoc*) | document |

Get standard font ID.

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

Parameters

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

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

## ◆ getStyles:()

- (unsigned int) getStyles: |  | (FSPDFDoc*) | document |

Get font styles.

Parameters

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

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

## ◆ initWithFont_file_path:face_index:charset:()

- (id) initWithFont_file_path: |  | (NSString *) | font_file_path
face_index: |  | (int) | face_index
charset: |  | (FSFontCharset) | 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 FSFontCharsetANSI and this should be one of these values.

## ◆ initWithFont_id:()

- (id) initWithFont_id: |  | (FSFontStandardID) | 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 FSFontStdIDCourier and this should be one of these values.

## ◆ initWithName:styles:charset:weight:()

- (id) initWithName: |  | (NSString *) | name
styles: |  | (unsigned int) | styles
charset: |  | (FSFontCharset) | charset
weight: |  | (int) | 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 FSFontStyleFixedPitch 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 FSFontCharsetANSI and this should be one of these values.
  [in] | weight | Original font weight. 0 means unspecified.

## ◆ initWithOther:()

- (id) initWithOther: |  | (FSFont*) | other |

Constructor, with another font object.

Parameters

  [in] | other | Another font object.

## ◆ isBold()

- (BOOL) isBold |  |  |

Judge whether current font is bold or not.

Returns
  YES means current font is bold, while NO means not.

## ◆ isCharSupported:document:()

- (BOOL) isCharSupported: |  | (unsigned int) | unicode
document: |  | (FSPDFDoc*) | 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
  YES means the character is supported in its font, while NO means not.

## ◆ isEmbedded:()

- (BOOL) isEmbedded: |  | (FSPDFDoc*) | document |

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

Parameters

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

Returns
  YES means the font is embedded in the specified PDF document, while NO means not.

## ◆ isEmpty()

- (BOOL) isEmpty |  |  |

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  YES means current object is empty, while NO means not.

## ◆ isItalic()

- (BOOL) isItalic |  |  |

Judge whether current font object is italic or not.

Returns
  YES means current font is italic, while NO means not.

## ◆ isStandardFont:()

- (BOOL) isStandardFont: |  | (FSPDFDoc*) | document |

Check whether current font is a standard font.

Parameters

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

Returns
  YES means current font is a standard font, while NO means not.

## ◆ isSupportEmbedded:()

- (BOOL) isSupportEmbedded: |  | (FSPDFDoc*) | 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
  YES means current font is supported to be embedded to the specified PDF document, while NO means not.

## ◆ isVertWriting:()

- (BOOL) isVertWriting: |  | (FSPDFDoc*) | document |

Check whether current font is vertical writing.

Parameters

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

Returns
  YES means current font is vertical writing, while NO means current font is not vertical writing.

## ◆ setEncoding:value:()

- (BOOL) setEncoding: |  | (FSPDFDoc*) | document
value: |  | (NSString *) | 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
  YES means success, while NO means failed.