TX Text Control .NET Server

GetFontFamilies Method

Method|Introduced in 16.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK as TXTextControl.Core.dll from the private NuGet feed or Text Control Offline Packages
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

Returns an array of strings specifying all supported fonts. These fonts depend on the formatting device set with the WPF.TextControl.FormattingPrinter or TextControl.FormattingPrinter property and on attributes set with the WPF.TextControl.FontSettings or TextControl.FontSettings property.

Syntax

public string[] GetFontFamilies();

Return Value

The return value is the list of available fonts.

Examples

The following XAML example shows how to bind a combo box to the FontFamily property using GetFontFamilies to fill the combo box with available font names.

<ComboBox
    Name="cbFontFamily"
    IsEditable="True"
    IsReadOnly="True"
    Width="150"
    DropDownOpened="cbFontFamily_DropDownOpened"
    Text="{Binding ElementName=textControl1, Path=InputFormat.FontFamily}" />

The following example changes the formatting applied to text entered at the end of a document by using InputFormat.GetFontFamilies.

textControl.Text = "Project summary";
textControl.InputPosition = new InputPosition(textControl.Text.Length);
InputFormat inputFormat = textControl.InputFormat;

string[] results = inputFormat.GetFontFamilies();
foreach (string text in results)
{
    Console.WriteLine(text);
}