In this article:

Description

Setting Up Formatted Text in User Interface

Setting Up Formatted Text Using Fore

XAML

HTML

RTF

Using Formatted Text

Article number: KB000034

Description

Use of RTF editor is implemented in different elements of platform objects that are used to display text. RTF editor allows for setting up a more detailed text formatting (ability to set up formatting for separate parts of text). Various captions supporting the IGxTitle interface can store formatting settings in the XAML or HTML formats.

NOTE. XAML format is no longer supported for storing of formatted text values. On specifying values in XAML format they are automatically converted to RTF format. Older values in XAML format are also converted.

The following elements support the use of formatted text:

Element that uses formatted text Fore property
Regular report table cells
Chart caption and chart axis caption
Labels on the chart
Workspace shapes text
Captions supporting the interface IGxTitle

Setting Up Formatted Text in User Interface

To set up text block formatting, select the required text and select the Format item in the context menu:

The dialog box that opens is identical to dialog boxes for setting up of text formatting but it allows for using additional fonts, which can be rendered by WPF technology.

IMPORTANT. When text size with set formatting is changed, spaces that can be at the end of the text are not taken into account. In this case, the workspace size may be calculated incorrectly for the element, which will display the formatted text.

Setting Up Formatted Text Using Fore

To set up formatted text using Fore, set value of the property for the required element. The list of available properties is specified in the table above. Depending on the text format, take into account the features of formats described below.

XAML

The text that is XAML markup is set as the value, the markup is given as settings of the TextBlock element:

"<?xml version=""1.0"" encoding=""utf-16""?>

<TextBlock FontFamily=""Arial"" FontStyle=""Normal"" FontWeight=""Bold"" FontSize=""13.3333333333333""

xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">Very<LineBreak />

<Run FontSize=""15.3333333333333"" Foreground=""#FF366092"">Important</Run><LineBreak />

<Run Foreground=""#FFE26B0A"" FontSize=""18.3333333333333"">Title</Run></TextBlock>";

General attributes used to format the whole text block are set up for the TextBlock element, which can contain:

NOTE. The TextBlock and Run elements have equal attributes for setting up text. Attributes of the Run element overlap similar attributes of the TextBlock element.

Mandatory attribute of the TextBlock element is xmlns. It determines WPF namespace. Description of the used TextBlock element is presented in MSDN. When creating markup, you can use description of the System.Windows.Controls.Textblock class.

HTML

The text that is HTML markup is set as the value. Main markup element is <Span>...</Span>. Formatted text is combination of <Span> elements:

<span style="font-family: Arial;font-size: 12pt;color: #000000;background-color: #366092;text-align: left;">

<span style="font-weight: bold;font-size: 10pt;font-family: inherit;">Very</span><br/>

<span style="color: #366092;font-weight: bold;font-size: 11pt;font-family: inherit;">Important</span><br/>

<span style="color: #e26b0a;font-weight: bold;font-size: 14pt;font-family: inherit;">Caption</span></span>

RTF

Presenting of the formatted text in RTF format requires knowledge of the format features. This information is mostly used by developers who work with various text editors. The TextConverter special class has been developed in the Fore language to convert text into various formats. The Export method belonging to this class can be used to get RTF text, for example, from the current HTML text. Below is example of the function that converts HTML text to RTF text:

Function HtmlToRtf(html: String): String;
Var
    Converter: ITextConverter;
Begin
    Converter := New TextConverter.Create;
    Return Converter.Export(html, TextFormat.Rtf);
End Function HtmlToRtf;

See also:

Developers Knowledge Base