FormattedText Class
Definition
The FormattedText class is targeted at programmers needing to add some simple text to a MIL visual.
public class FormattedText
Constructors
| Name | Description |
|---|---|
| FormattedText | Construct a FormattedText object. |
FormattedText Constructor
Construct a FormattedText object.
public FormattedText(string textToFormat, System.Globalization.CultureInfo culture, Avalonia.Media.FlowDirection flowDirection, Avalonia.Media.Typeface typeface, double emSize, Avalonia.Media.IBrush foreground)
Parameters
textToFormat string
String of text to be displayed.
culture System.Globalization.CultureInfo
Culture of text.
flowDirection Avalonia.Media.FlowDirection
Flow direction of text.
typeface Avalonia.Media.Typeface
Type face used to display text.
emSize double
Font em size in visual units (1/96 of an inch).
foreground Avalonia.Media.IBrush
Foreground brush used to render text.
Methods
| Name | Description |
|---|---|
| BuildGeometry | Obtains geometry for the text, including underlines and strikethroughs. |
| BuildHighlightGeometry (2 overloads) | Builds a highlight geometry object. |
| GetMaxTextWidths | Obtains a copy of the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The maxTextWidths array overrides the MaxTextWidth property. |
| SetCulture (2 overloads) | Sets or changes the culture for the text object. |
| SetFontFamily (4 overloads) | Sets or changes the font family for the text object |
| SetFontFeatures (2 overloads) | Sets or changes the font features for the text object |
| SetFontSize (2 overloads) | Sets or changes the font em size measured in MIL units |
| SetFontStyle (2 overloads) | Sets or changes the font style |
| SetFontTypeface (2 overloads) | Sets or changes the type face |
| SetFontWeight (2 overloads) | Sets or changes the font weight |
| SetForegroundBrush (2 overloads) | Sets foreground brush used for drawing text |
| SetMaxTextWidths | Sets the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The maxTextWidths array overrides the MaxTextWidth property. |
| SetTextDecorations (2 overloads) | Sets or changes the text decorations |
BuildGeometry Method
Obtains geometry for the text, including underlines and strikethroughs.
public Avalonia.Media.Geometry BuildGeometry(Avalonia.Point origin)
Parameters
origin Avalonia.Point
The left top origin of the resulting geometry.
Returns
The geometry returned contains the combined geometry of all of the glyphs, underlines and strikeThroughs that represent the formatted text. Overlapping contours are merged by performing a Boolean union operation.
BuildHighlightGeometry overloads
BuildHighlightGeometry Method
Builds a highlight geometry object.
public Avalonia.Media.Geometry BuildHighlightGeometry(Avalonia.Point origin)
Parameters
origin Avalonia.Point
The origin of the highlight region
Returns
Geometry that surrounds the text.
BuildHighlightGeometry Method
Builds a highlight geometry object for a given character range.
public Avalonia.Media.Geometry BuildHighlightGeometry(Avalonia.Point origin, int startIndex, int count)
Parameters
origin Avalonia.Point
The origin of the highlight region.
startIndex int
The start index of initial character the bounds should be obtained for.
count int
The number of characters the bounds should be obtained for.
Returns
Geometry that surrounds the specified character range.
GetMaxTextWidths Method
Obtains a copy of the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The maxTextWidths array overrides the MaxTextWidth property.
public double[] GetMaxTextWidths()
Returns
double[]
The copy of max text width array
SetCulture overloads
SetCulture Method
Sets or changes the culture for the text object.
public void SetCulture(System.Globalization.CultureInfo culture)
Parameters
culture System.Globalization.CultureInfo
The new culture for the text object.
SetCulture Method
Sets or changes the culture for the text object.
public void SetCulture(System.Globalization.CultureInfo culture, int startIndex, int count)
Parameters
culture System.Globalization.CultureInfo
The new culture for the text object.
startIndex int
The start index of initial character to apply the change to.
count int
The number of characters the change should be applied to.
SetFontFamily overloads
SetFontFamily Method
Sets or changes the font family for the text object
public void SetFontFamily(Avalonia.Media.FontFamily fontFamily)
Parameters
fontFamily Avalonia.Media.FontFamily
Font family