Class TextDecoration
Lines drawn with text (CSS Text Decoration 4).
public sealed record TextDecoration : IEquatable<TextDecoration>
- Inheritance
-
TextDecoration
- Implements
- Inherited Members
Examples
// Font families come from a collection; later families cover what the first lacks.
FontCollection fonts = new();
fonts.AddFile(System.IO.Path.Combine(folder, "NotoSans-Regular.ttf"));
fonts.AddFile(System.IO.Path.Combine(folder, "NotoSansArabic-Regular.ttf"));
fonts.TryGetFamily("Noto Sans", out FontFamily latin);
fonts.TryGetFamily("Noto Sans Arabic", out FontFamily arabic);
// Styles nest: the inner span keeps the outer one's size and adds a color and an underline.
RichText text = new RichTextBuilder()
.Append("Peace is ")
.Push(new TextStyle { Size = 20 })
.Append("\u0633\u0644\u0627\u0645 ")
.Push(new TextStyle { Color = new Rgba8(200, 30, 30, 255), Decoration = new TextDecoration() })
.Append("in Arabic")
.Pop()
.Pop()
.AddPlaceholder(new Placeholder(16, 16, PlaceholderAlignment.Middle))
.ToRichText();
ParagraphStyle style = new()
{
DefaultStyle = new TextStyle { FontFamilies = [latin, arabic], Size = 16, LineHeight = LineHeight.Multiple(1.4f) },
Align = TextAlign.Justify,
LineBreaking = new LineBreakOptions(WordBreak: WordBreak.Normal),
};
// Shaped once: lay it out at any width later.
Paragraph paragraph = Paragraph.Create(text, style);
Properties
Color
Gets the lines' color; the text's color when unset.
public Rgba8? Color { get; init; }
Property Value
Lines
Gets which lines are drawn.
public TextDecorationLines Lines { get; init; }
Property Value
Paint
Gets the lines' paint; overrides Color.
public ITextPaint? Paint { get; init; }
Property Value
SkipInk
Gets whether underlines and overlines leave gaps where glyphs cross them.
public TextDecorationSkipInk SkipInk { get; init; }
Property Value
Style
Gets how the lines are drawn.
public TextDecorationStyle Style { get; init; }
Property Value
Thickness
Gets the line thickness in canvas units; from the font's post and OS/2 values when unset.
public float? Thickness { get; init; }
Property Value
UnderlineOffset
Gets how far below the baseline the underline sits, in canvas units; from the font's post table when unset.
public float? UnderlineOffset { get; init; }