Skip to main content

TextElementFormatting Struct

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

Formatting snapshot for properties defined on Avalonia.Controls.Documents.RichTextElement. Shared across all node types (inline, block, table row, etc.).

public struct TextElementFormatting

Inheritance: ValueType -> TextElementFormatting

Implements: IEquatable<TextElementFormatting>

Remarks​

Captures the inheritable visual properties that every Avalonia.Controls.Documents.RichTextElement can carry: font family/size/weight/style/stretch, foreground, background, letter spacing, and font features. Avalonia.Controls.Documents.TextModel.Formatting.InlineFormatting and Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting carry only what is specific to them.

Stored on Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode so every snapshot node (inline, block, table-row, image, etc.) can carry base-level formatting without type-specific snapshot subclasses.

Methods​

NameDescription
Equals (2 overloads)No summary available.
GetHashCodeNo summary available.
ToStringNo summary available.

Equals overloads​

Equals Method​

public bool Equals(Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting other)
Parameters​

other Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

GetHashCode Method​

public int GetHashCode()

Returns​

int

ToString Method​

public string ToString()

Returns​

string

Properties​

NameDescription
BackgroundArgbPacked ARGB value for background color. Null means not explicitly set.
BackgroundColorGets the background color if set, otherwise null.
DefaultDefault formatting with no explicit values set.
FontFamilyThe font family name. Null if using inherited/default font.
FontFeaturesOpenType font features (e.g. ligatures, stylistic sets). Default means not explicitly set.
FontSizeThe font size in device-independent pixels. Null means not explicitly set.
FontStretchThe font stretch (e.g., Normal, Condensed, Expanded). Null means not explicitly set.
FontStyleThe font style (e.g., Normal, Italic, Oblique). Null means not explicitly set.
FontWeightThe font weight (e.g., Normal, Bold). Null means not explicitly set.
ForegroundArgbPacked ARGB value for foreground color. Null means not explicitly set.
ForegroundColorGets the foreground color if set, otherwise null.
HasBackgroundGets whether a background color is explicitly set.
HasForegroundGets whether a foreground color is explicitly set.
LetterSpacingThe letter spacing in pixels. Null means not explicitly set. Default is 0 (normal spacing).

BackgroundArgb Property​

Packed ARGB value for background color. Null means not explicitly set.

public Nullable<uint> BackgroundArgb { get; set; }

BackgroundColor Property​

Gets the background color if set, otherwise null.

public Nullable<Avalonia.Media.Color> BackgroundColor { get; set; }

Default Property​

Default formatting with no explicit values set.

public Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting Default { get; set; }

FontFamily Property​

The font family name. Null if using inherited/default font.

public string FontFamily { get; set; }

FontFeatures Property​

OpenType font features (e.g. ligatures, stylistic sets). Default means not explicitly set.

public Avalonia.Media.FontFeature[] FontFeatures { get; set; }

Remarks​

Do not write through this array. A snapshot is read by a serializer running on another thread while the document carries on being edited, and the array is handed out by reference, so a write here is a write the reader may see halfway through. Build a new array and assign it instead.

FontSize Property​

The font size in device-independent pixels. Null means not explicitly set.

public Nullable<double> FontSize { get; set; }

FontStretch Property​

The font stretch (e.g., Normal, Condensed, Expanded). Null means not explicitly set.

public Nullable<Avalonia.Media.FontStretch> FontStretch { get; set; }

FontStyle Property​

The font style (e.g., Normal, Italic, Oblique). Null means not explicitly set.

public Nullable<Avalonia.Media.FontStyle> FontStyle { get; set; }

FontWeight Property​

The font weight (e.g., Normal, Bold). Null means not explicitly set.

public Nullable<Avalonia.Media.FontWeight> FontWeight { get; set; }

ForegroundArgb Property​

Packed ARGB value for foreground color. Null means not explicitly set.

public Nullable<uint> ForegroundArgb { get; set; }

ForegroundColor Property​

Gets the foreground color if set, otherwise null.

public Nullable<Avalonia.Media.Color> ForegroundColor { get; set; }

HasBackground Property​

Gets whether a background color is explicitly set.

public bool HasBackground { get; set; }

HasForeground Property​

Gets whether a foreground color is explicitly set.

public bool HasForeground { get; set; }

LetterSpacing Property​

The letter spacing in pixels. Null means not explicitly set. Default is 0 (normal spacing).

public Nullable<double> LetterSpacing { get; set; }