Class DecorationShape
One decoration line over a decorated stretch of one text line: an underline, overline or line-through at one position and thickness for the whole stretch (the lowest underline and thickest line among its fonts, as CSS), cut where glyphs cross an underline or overline when SkipInk is Auto.
public sealed class DecorationShape
- Inheritance
-
DecorationShape
- Inherited Members
- Extension Methods
Examples
TextStyle underlined = new()
{
FontFamilies = [family],
Decoration = new TextDecoration { Lines = TextDecorationLines.Underline, Style = TextDecorationStyle.Wavy },
};
TextLayout layout = Paragraph.Create("Typography, quickly", new ParagraphStyle { DefaultStyle = underlined }).Layout(400);
foreach (DecorationShape line in layout.Decorations)
{
// Top and Thickness place the line; Segments skip the descenders of y, p, g and q.
System.Console.WriteLine($"{line.Line} at {line.Top}: {line.Segments.Count} pieces");
}
// Or everything as outlines, to fill with any path renderer.
PathRecorder path = new();
layout.ToPath(path);
Properties
Color
Gets the line's color: the decoration's, else the text's.
public Rgba8 Color { get; }
Property Value
Line
Gets which line this is: one of underline, overline and line-through.
public TextDecorationLines Line { get; }
Property Value
LineIndex
Gets the index of the text line in Lines.
public int LineIndex { get; }
Property Value
Paint
Gets the line's paint, when the decoration has one.
public ITextPaint? Paint { get; }
Property Value
Segments
Gets the pieces the line is drawn in, left to right, skip-ink gaps already cut.
public IReadOnlyList<DecorationSegment> Segments { get; }
Property Value
Style
Gets how the line is drawn.
public TextDecorationStyle Style { get; }
Property Value
StyleIndex
Gets the style of the decorated text: 0 for the paragraph's default style, else 1 plus the span's index.
public int StyleIndex { get; }
Property Value
Thickness
Gets the line's thickness.
public float Thickness { get; }
Property Value
Top
Gets the y of the line's top edge (for a double line, the first line's).
public float Top { get; }
Property Value
Methods
AddTo(IGlyphOutlineSink)
Writes the line's geometry as filled shapes: a rectangle per segment for solid lines, two for double lines (a pixel apart, as Chromium draws them), round dots one thickness wide and one thickness apart for dotted lines, dashes three thicknesses long for dashed lines, and a wave of amplitude 1.5 thicknesses for wavy lines.
public void AddTo(IGlyphOutlineSink sink)
Parameters
sinkIGlyphOutlineSinkWhere the outlines go, in layout coordinates with y down.
Exceptions
- ArgumentNullException
sinkis null.