Vixen
02b45cc4
csharp
public sealed class TextLine

An element's text as the runs it is actually drawn in.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

One run per face, in text order. Most lines have exactly one, and the code below is written so that a line that does costs no more than the single-run type it replaced. A second run appears when a character is not in the first font — FontRegistry hands each grapheme cluster to the first face of the declaration's chain that covers it — and the same shape will carry a rich-text span whose size or weight differs.

⚠ Composition happens in pixels, and that is not an implementation detail. Runs cannot be added up in design units: a 1000-unit face and a 2048-unit face measure an em differently, so an advance from one means nothing beside an advance from the other. Everything here — width, baseline, caret offsets — is in pixels for that reason, and it is why Vixen.Ui.Text's size-independent ShapedText is deliberately single-font.

Fields and properties (6)

  • public int Start

    Where this line's text begins in the element's, as a UTF-16 index.

  • public int Length

    How many UTF-16 units it covers.

  • public ImmutableArray<TextRun> Runs

    The runs, in text order.

  • public float Width

    How wide the line is, in pixels, not counting whitespace at its end.

  • public float Height

    How tall it is, in pixels.

  • public float Baseline

    How far below the top of the line its shared baseline sits, in pixels.

Methods (5)

  • public TextLine(ImmutableArray<TextRun> runs, float width = NaN)

    Builds a line from its runs.

  • public float PenOf(int run)

    Where a run begins, in pixels from the start of the line.

  • public void Place(List<PositionedGlyph> into)

    Places every glyph of every run relative to the start of the line.

  • public float CaretOffset(int index)

    Where a caret sits, in pixels from the start of the line.

  • public int CaretIndexAt(float x)

    Which caret index a distance along the line lands on.

Used by (10)

  • CodeEditorVixen.Ui.Controls.Advanced
  • DrawListBuilderVixen.Ui
  • FontFallbackTestsVixen.Ui.Tests
  • FontRegistryTestsVixen.Ui.Tests
  • TextFieldVixen.Ui.Controls
  • TextFieldTestsVixen.Ui.Controls.Tests
  • TextLayoutVixen.Ui
  • TextTestsVixen.Ui.Tests
  • TextWrapTestsVixen.Ui.Tests
  • UiElementVixen.Ui