Skip to main content

TextOptions Struct

Definition

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia

Provides options for controlling text rendering behavior, including rendering mode, hinting mode, and baseline pixel alignment. Used to configure how text appears within visual elements.

public struct TextOptions

Inheritance: ValueType -> TextOptions

Implements: IEquatable<TextOptions>

Remarks

TextOptions encapsulates settings that influence the clarity, sharpness, and positioning of rendered text. These options can be applied to visual elements to customize text appearance for different display scenarios, such as optimizing for readability at small font sizes or ensuring pixel-perfect alignment. The struct supports merging with other instances to inherit unspecified values, and exposes attached properties for use with visuals.

Methods

NameDescription
Equals (2 overloads)No summary available.
GetBaselinePixelAlignmentGets the BaselinePixelAlignment attached property for a visual.
GetHashCodeNo summary available.
GetTextHintingModeGets the TextHintingMode attached property for a visual.
GetTextOptionsGets the TextOptions attached value for a visual.
GetTextRenderingModeGets the TextRenderingMode attached property for a visual.
MergeWithMerges this instance with other using inheritance semantics: unspecified values on this instance are taken from other.
SetBaselinePixelAlignmentSets the BaselinePixelAlignment attached property for a visual.
SetTextHintingModeSets the TextHintingMode attached property for a visual.
SetTextOptionsSets the TextOptions attached value for a visual.
SetTextRenderingModeSets the TextRenderingMode attached property for a visual.
ToStringNo summary available.

Equals overloads

Equals Method

public bool Equals(Avalonia.Media.TextOptions other)
Parameters

other Avalonia.Media.TextOptions

Returns

bool

Equals Method

public bool Equals(object obj)
Parameters

obj object

Returns

bool

GetBaselinePixelAlignment Method

Gets the BaselinePixelAlignment attached property for a visual.

public Avalonia.Media.BaselinePixelAlignment GetBaselinePixelAlignment(Avalonia.Visual visual)

Parameters

visual Avalonia.Visual

Returns

Avalonia.Media.BaselinePixelAlignment

GetHashCode Method

public int GetHashCode()

Returns

int

GetTextHintingMode Method

Gets the TextHintingMode attached property for a visual.

public Avalonia.Media.TextHintingMode GetTextHintingMode(Avalonia.Visual visual)

Parameters

visual Avalonia.Visual

Returns

Avalonia.Media.TextHintingMode

GetTextOptions Method

Gets the TextOptions attached value for a visual.

public Avalonia.Media.TextOptions GetTextOptions(Avalonia.Visual visual)

Parameters

visual Avalonia.Visual

Returns

Avalonia.Media.TextOptions

GetTextRenderingMode Method

Gets the TextRenderingMode attached property for a visual.

public Avalonia.Media.TextRenderingMode GetTextRenderingMode(Avalonia.Visual visual)

Parameters

visual Avalonia.Visual

Returns

Avalonia.Media.TextRenderingMode

MergeWith Method

Merges this instance with other using inheritance semantics: unspecified values on this instance are taken from other.

public Avalonia.Media.TextOptions MergeWith(Avalonia.Media.TextOptions other)

Parameters

other Avalonia.Media.TextOptions

Returns

Avalonia.Media.TextOptions

SetBaselinePixelAlignment Method

Sets the BaselinePixelAlignment attached property for a visual.

public void SetBaselinePixelAlignment(Avalonia.Visual visual, Avalonia.Media.BaselinePixelAlignment value)

Parameters

visual Avalonia.Visual

value Avalonia.Media.BaselinePixelAlignment

SetTextHintingMode Method

Sets the TextHintingMode attached property for a visual.

public void SetTextHintingMode(Avalonia.Visual visual, Avalonia.Media.TextHintingMode value)

Parameters

visual Avalonia.Visual

value Avalonia.Media.TextHintingMode

SetTextOptions Method

Sets the TextOptions attached value for a visual.

public void SetTextOptions(Avalonia.Visual visual, Avalonia.Media.TextOptions value)

Parameters

visual Avalonia.Visual

value Avalonia.Media.TextOptions

SetTextRenderingMode Method

Sets the TextRenderingMode attached property for a visual.

public void SetTextRenderingMode(Avalonia.Visual visual, Avalonia.Media.TextRenderingMode value)

Parameters

visual Avalonia.Visual

value Avalonia.Media.TextRenderingMode

ToString Method

public string ToString()

Returns

string

Properties

NameDescription
BaselinePixelAlignmentGets a value indicating whether the text baseline should be aligned to the pixel grid.
TextHintingModeGets the text rendering hinting mode used to optimize the display of text.
TextRenderingModeGets the text rendering mode used to control how text glyphs are rendered.

BaselinePixelAlignment Property

Gets a value indicating whether the text baseline should be aligned to the pixel grid.

public Avalonia.Media.BaselinePixelAlignment BaselinePixelAlignment { get; set; }

Remarks

When enabled, the vertical position of the text baseline is snapped to whole pixel boundaries. This ensures consistent sharpness and reduces blurriness caused by fractional positioning, particularly at small font sizes or low DPI settings.

TextHintingMode Property

Gets the text rendering hinting mode used to optimize the display of text.

public Avalonia.Media.TextHintingMode TextHintingMode { get; set; }

Remarks

The hinting mode determines how text is rendered to improve clarity and readability, especially at small font sizes. Changing this value may affect the appearance of text depending on the rendering engine and display device.

TextRenderingMode Property

Gets the text rendering mode used to control how text glyphs are rendered.

public Avalonia.Media.TextRenderingMode TextRenderingMode { get; set; }