FontCollection Class — NXOpen Python API Reference 12.0.0 documentation

# FontCollection Class

class `NXOpen.``FontCollection`

  Bases: `object`

  Represents a collection of typographical fonts (for example, Arial, OldEnglish)

  To obtain an instance of this class, refer to `NXOpen.BasePart`

  New in version NX3.0.0.

# Methods

Method | Description
--- | ---
AddFont | Adds a font to the part.
DoesFontExist | Finds out whether the specified ID is associated with a font
GetFontName | Returns the name for the font that has the specified integer ID
GetFontType | Returns the font type of the font at the provided index
GetLength | Returns the number of fonts in the part
ReplaceFont | Replaces a font name and type at the given font index

# Enumerations

FontCollectionType Enumeration | Specifies the type of font

# Method Detail

## AddFont

`FontCollection.``AddFont`

  Overloaded method AddFont

  - `AddFont(fontName)`
  - `AddFont(fontName, type)`

  `-------------------------------------`

  Adds a font to the part. This will only add NX fonts. To add Standard fonts, use the overloaded `FontCollection.AddFont()` routine that accepts the font type. If the font name already exists in the part, this will return the existing font index.

  Signature `AddFont(fontName)`

  Parameters: | fontName (str) – Font name
  Returns: | Integer ID that the method assigns to the font
  Return type: | int

  New in version NX3.0.0.

  License requirements: None.

  `-------------------------------------`

  Adds a font to the part. This can be used to create both NX and Standard fonts. If the font name already exists in the part, this will return the existing font index.

  Signature `AddFont(fontName, type)`

  Parameters:

  - fontName (str) – Font name
  - type (`NXOpen.FontCollectionType`) – Type of the font

  Returns: | Integer ID that the method assigns to the font
  Return type: | int

  New in version NX7.5.0.

  License requirements: None.

  `-------------------------------------`

## DoesFontExist

`FontCollection.``DoesFontExist`

  Finds out whether the specified ID is associated with a font

  Signature `DoesFontExist(fontIndex)`

  Parameters: | fontIndex (int) – ID of the font
  Returns: | True iff the font exists
  Return type: | bool

  New in version NX3.0.0.

  License requirements: None.

## GetFontName

`FontCollection.``GetFontName`

  Returns the name for the font that has the specified integer ID

  Signature `GetFontName(fontIndex)`

  Parameters: | fontIndex (int) – The ID for the font
  Returns: | The font’s name
  Return type: | str

  New in version NX3.0.0.

  License requirements: None.

## GetFontType

`FontCollection.``GetFontType`

  Returns the font type of the font at the provided index

  Signature `GetFontType(fontIndex)`

  Parameters: | fontIndex (int) – ID of the font
  Returns: | Type of the font
  Return type: | `NXOpen.FontCollectionType`

  New in version NX7.5.0.

  License requirements: None.

## GetLength

`FontCollection.``GetLength`

  Returns the number of fonts in the part

  Signature `GetLength()`

  Returns: |
  Return type: | int

  New in version NX3.0.0.

  License requirements: None.

## ReplaceFont

`FontCollection.``ReplaceFont`

  Replaces a font name and type at the given font index

  Signature `ReplaceFont(fontIndex, type, fontName)`

  Parameters:

  - fontIndex (int) – ID of the font
  - type (`NXOpen.FontCollectionType`) – New type of the font
  - fontName (str) – New name of the font

  New in version NX7.5.0.

  License requirements: None.