TextOptions Struct
Definition
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
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
| Name | Description |
|---|---|
| Equals (2 overloads) | No summary available. |
| GetBaselinePixelAlignment | Gets the BaselinePixelAlignment attached property for a visual. |
| GetHashCode | No summary available. |
| GetTextHintingMode | Gets the TextHintingMode attached property for a visual. |
| GetTextOptions | Gets the TextOptions attached value for a visual. |
| GetTextRenderingMode | Gets the TextRenderingMode attached property for a visual. |
| MergeWith | Merges this instance with other using inheritance semantics: unspecified values on this instance are taken from other. |
| SetBaselinePixelAlignment | Sets the BaselinePixelAlignment attached property for a visual. |
| SetTextHintingMode | Sets the TextHintingMode attached property for a visual. |
| SetTextOptions | Sets the TextOptions attached value for a visual. |
| SetTextRenderingMode | Sets the TextRenderingMode attached property for a visual. |
| ToString | No 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
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
GetTextOptions Method
Gets the TextOptions attached value for a visual.
public Avalonia.Media.TextOptions GetTextOptions(Avalonia.Visual visual)
Parameters
visual Avalonia.Visual
Returns
GetTextRenderingMode Method
Gets the TextRenderingMode attached property for a visual.
public Avalonia.Media.TextRenderingMode GetTextRenderingMode(Avalonia.Visual visual)
Parameters
visual Avalonia.Visual
Returns
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
SetBaselinePixelAlignment Method
Sets the BaselinePixelAlignment attached property for a visual.
public void SetBaselinePixelAlignment(Avalonia.Visual visual, Avalonia.Media.BaselinePixelAlignment value)
Parameters
visual Avalonia.Visual
SetTextHintingMode Method
Sets the TextHintingMode attached property for a visual.
public void SetTextHintingMode(Avalonia.Visual visual, Avalonia.Media.TextHintingMode value)
Parameters
visual Avalonia.Visual
SetTextOptions Method
Sets the TextOptions attached value for a visual.
public void SetTextOptions(Avalonia.Visual visual, Avalonia.Media.TextOptions value)
Parameters
visual Avalonia.Visual
SetTextRenderingMode Method
Sets the TextRenderingMode attached property for a visual.
public void SetTextRenderingMode(Avalonia.Visual visual, Avalonia.Media.TextRenderingMode value)
Parameters
visual Avalonia.Visual
ToString Method
public string ToString()
Returns
string
Properties
| Name | Description |
|---|---|
| BaselinePixelAlignment | Gets a value indicating whether the text baseline should be aligned to the pixel grid. |
| TextHintingMode | Gets the text rendering hinting mode used to optimize the display of text. |
| TextRenderingMode | Gets 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; }