FontFamily Property
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. Core. SDK TXTextControl.from the private NuGet feed or Text Control Offline PackagesCore. dll
- Also in
TXTextControl.asTextControl. ASP. SDK TXTextControl.dll
Description
Gets or sets the font family at the current input position. If text is selected, the property specifies the font family of the whole selected text.
Syntax
public string FontFamily { get; set; }Public Property FontFamily As StringExamples
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}" />private void cbFontFamily_DropDownOpened(object sender, EventArgs e) {
cbFontFamily.ItemsSource = textControl1.InputFormat.GetFontFamilies();
}Private Sub cbFontFamily_DropDownOpened(sender As Object, e As EventArgs)
cbFontFamily.ItemsSource = textControl1.InputFormat.GetFontFamilies()
End SubThe following example changes the formatting applied to text entered at the end of a document by using InputFormat.FontFamily.
textControl.Text = "Project summary";
textControl.InputPosition = new InputPosition(textControl.Text.Length);
InputFormat inputFormat = textControl.InputFormat;
inputFormat.FontFamily = "Arial";
if (!string.IsNullOrWhiteSpace(inputFormat.FontFamily))
{
Console.WriteLine($"Font Family: {inputFormat.FontFamily}");
}textControl.Text = "Project summary"
textControl.InputPosition = New InputPosition(textControl.Text.Length)
Dim inputFormat As InputFormat = textControl.InputFormat
inputFormat.FontFamily = "Arial"
If Not String.IsNullOrWhiteSpace(inputFormat.FontFamily) Then
Console.WriteLine($"Font Family: {inputFormat.FontFamily}")
End IfRemarks
The property returns null when the text selection contains multiple characters with mixed font names.