Item Property

Applies to TestComplete 15.47, last modified on January 20, 2023
This property is provided by the legacy OCR plugin. In version 12.60, the plugin was replaced with the new Optical Character Recognition plugin powered by Google Cloud Vision API. To learn more, see Optical Character Recognition.
The legacy OCR plugin was removed from TestComplete in version 12.60. If you need to use objects, methods, and properties provided by the legacy plugin with this version of TestComplete, please contact our Customer Care team. The legacy OCR plugin was restored in TestComplete version 14.0. To use the objects, methods, and properties with this or later TestComplete version, you need to install and enable the plugin manually.

Description

The FontCollection.Item property returns an item specified by its index in the given font collection represented by the FontCollection object.

Declaration

FontCollectionObj.Item(Index)

Read-Only Property A Font object
FontCollectionObj An expression, variable or parameter that specifies a reference to a FontCollection object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

The index of the desired font in the font collection. The index ranges between 0 and FontCollection.Count - 1.

Property Value

A Font object that represents the desired font collection item.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the Item property in square brackets: Item[Index].

Example

The code below obtains the font collection specified for an object. After that, the routine iterates through the items of the font collection and posts the names of these items to the test log.

JavaScript, JScript

function FontCollection()
{
  var Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1);
  
  //...
  
  // Obtains the font collection specified for the object
  var Fonts = OCR.CreateObject(Obj).CreateOptions.Fonts;
  // Iterates through the font collection items
  for (var i = 0; i < Fonts.Count; i++)
  {
    // Obtains the current font
    var FontItem = Fonts.Item(i);
    // Posts the font name to the test log
    Log.Message(FontItem.Name);
  }

}

Python

def FontCollection():
  Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  # ...
  # Obtains the font collection specified for the object
  Fonts = OCR.CreateObject(Obj).CreateOptions().Fonts
  # Iterates through the font collection items
  for i in range(0, Fonts.Count):
    # Obtains the current font
    FontItem = Fonts.Item[i]
    # Posts the font name to the test log
    Log.Message(FontItem.Name)

VBScript

Sub FontCollection

  Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  
  '...
  
  ' Obtains the font collection specified for the object
  Set Fonts = OCR.CreateObject(Obj).CreateOptions.Fonts
  ' Iterates through the font collection items
  For i = 0 to (Fonts.Count - 1)
    ' Obtains the current font
    Set FontItem = Fonts.Item(i)
    ' Posts the font name to the test log
    Log.Message(FontItem.Name)
  Next

End Sub

DelphiScript

function FontCollection;
var Obj, Fonts, i, FontItem;
begin

  Obj := Sys.Process('notepad').Window('Notepad', 'Untitled - Notepad', 1);
  
  //...
  
  // Obtains the font collection specified for the object
  Fonts := OCR.CreateObject(Obj).CreateOptions.Fonts;
  // Iterates through the font collection items
  for i := 0 to (Fonts.Count - 1) do
  begin
    // Obtains the current font
    FontItem := Fonts.Item[i];
    // Posts the font name to the test log
    Log.Message(FontItem.Name);
  end;

end;

C++Script, C#Script

function FontCollection()
{
  var Obj = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 1);
  
  //...
  
  // Obtains the font collection specified for the object
  var Fonts = OCR["CreateObject"](Obj)["CreateOptions"]["Fonts"];
  // Iterates through the font collection items
  for (var i = 0; i < Fonts["Count"]; i++)
  {
    // Obtains the current font
    var FontItem = Fonts["Item"](i);
    // Posts the font name to the test log
    Log["Message"]( FontItem["Name"] );
  }

}

See Also

FontCollection.Count
FontCollection.Add
Font Object
Using Optical Character Recognition

Highlight search results