Count Property

Applies to TestComplete 14.10, last modified on June 5, 2019
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.Count property returns the number of fonts in the font collection represented by the FontCollection object.

Declaration

FontCollectionObj.Count

Read-Only Property Integer
FontCollectionObj An expression, variable or parameter that specifies a reference to a FontCollection object

Applies To

The property is applied to the following object:

Property Value

An integer value that denotes the number of fonts in the font collection. Each font in the collection is represented by the Font object.

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
  pass
  
  # 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.Item
FontCollection.Add
Font Object
Using Optical Character Recognition

Highlight search results