The Optical Character Recognition feature provided by the OCR plugin is deprecated. It was removed from TestComplete in version 12.60 and is no longer available for later versions. Instead, TestComplete version 12.60 introduces the new Optical Character Recognition engine featuring Google Cloud Vision API. To learn more, see Optical Character Recognition. If you need to use the legacy feature, please contact our Customer Care team. |
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