Table of Contents

Struct CaretLine

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

A caret segment across the line: vertical in horizontal layouts, horizontal in vertical ones.

public readonly record struct CaretLine : IEquatable<CaretLine>
Implements
Inherited Members

Examples

// A click: the nearest caret position, then where to draw the caret.
TextPosition position = layout.HitTest(new System.Numerics.Vector2(40, 30));
Caret caret = layout.GetCaret(position);
CaretLine bar = caret.Primary;                     // x, top and bottom; Secondary at a bidi boundary

// Arrow keys: logical moves, and line moves that keep the column.
TextPosition right = layout.MoveCaret(position, CaretMove.NextGrapheme);
TextPosition down = layout.MoveCaret(position, CaretMove.LineDown, preferredX: bar.X);

// A selection: rectangles to fill, one per visually contiguous piece on each line.
IReadOnlyList<TextBounds> highlight = layout.GetSelectionRects(position.Index, down.Index);
Egami.Fonts.Unicode.TextSegment word = layout.GetWordBoundary(position.Index); // double-click

Constructors

CaretLine(float, float, float)

A caret segment across the line: vertical in horizontal layouts, horizontal in vertical ones.

public CaretLine(float X, float Top, float Bottom)

Parameters

X float

The caret's x; in vertical layouts, its y.

Top float

The top of the segment; in vertical layouts, its left end.

Bottom float

The bottom of the segment; in vertical layouts, its right end.

Examples

// A click: the nearest caret position, then where to draw the caret.
TextPosition position = layout.HitTest(new System.Numerics.Vector2(40, 30));
Caret caret = layout.GetCaret(position);
CaretLine bar = caret.Primary;                     // x, top and bottom; Secondary at a bidi boundary

// Arrow keys: logical moves, and line moves that keep the column.
TextPosition right = layout.MoveCaret(position, CaretMove.NextGrapheme);
TextPosition down = layout.MoveCaret(position, CaretMove.LineDown, preferredX: bar.X);

// A selection: rectangles to fill, one per visually contiguous piece on each line.
IReadOnlyList<TextBounds> highlight = layout.GetSelectionRects(position.Index, down.Index);
Egami.Fonts.Unicode.TextSegment word = layout.GetWordBoundary(position.Index); // double-click

Properties

Bottom

The bottom of the segment; in vertical layouts, its right end.

public float Bottom { get; init; }

Property Value

float

Top

The top of the segment; in vertical layouts, its left end.

public float Top { get; init; }

Property Value

float

X

The caret's x; in vertical layouts, its y.

public float X { get; init; }

Property Value

float