Table of Contents

Struct TabStop

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

An explicit tab stop.

public readonly record struct TabStop : IEquatable<TabStop>
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);

Constructors

TabStop(float, TabAlignment)

An explicit tab stop.

public TabStop(float Position, TabAlignment Alignment = TabAlignment.Start)

Parameters

Position float

The stop's distance from the line's start, in canvas units.

Alignment TabAlignment

How the text after the tab aligns on the stop.

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

Alignment

How the text after the tab aligns on the stop.

public TabAlignment Alignment { get; init; }

Property Value

TabAlignment

Position

The stop's distance from the line's start, in canvas units.

public float Position { get; init; }

Property Value

float