Table of Contents

Class DecorationShape

Namespace
Egami.Fonts.Layout
Assembly
Egami.Fonts.dll

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

Rgba8

Line

Gets which line this is: one of underline, overline and line-through.

public TextDecorationLines Line { get; }

Property Value

TextDecorationLines

LineIndex

Gets the index of the text line in Lines.

public int LineIndex { get; }

Property Value

int

Paint

Gets the line's paint, when the decoration has one.

public ITextPaint? Paint { get; }

Property Value

ITextPaint

Segments

Gets the pieces the line is drawn in, left to right, skip-ink gaps already cut.

public IReadOnlyList<DecorationSegment> Segments { get; }

Property Value

IReadOnlyList<DecorationSegment>

Style

Gets how the line is drawn.

public TextDecorationStyle Style { get; }

Property Value

TextDecorationStyle

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

int

Thickness

Gets the line's thickness.

public float Thickness { get; }

Property Value

float

Top

Gets the y of the line's top edge (for a double line, the first line's).

public float Top { get; }

Property Value

float

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

sink IGlyphOutlineSink

Where the outlines go, in layout coordinates with y down.

Exceptions

ArgumentNullException

sink is null.