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.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