Vixen
dd8b0a81
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 and per bidi level, held in text order and drawn in visual 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 — or when the text changes direction, and the same shape will carry a rich-text span whose size or weight differs.

⚠ Runs is logical and PenOf is visual, and the two are deliberately not the same order. UAX#9's L2 decides where each run is drawn, and that is applied to the pens alone: everything that walks the runs — the caret, Start, Length — wants them in the order the text is read. A consumer that needs to paint left to right sorts by PenOf; one that needs to reason about the characters does not have to know reordering happened at all.

⚠ 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 (7)

  • 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 Offset

    Where the first glyph sits, in pixels from the start of the line box.

  • 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 (9)

  • public TextLine(ImmutableArray<TextRun> runs, float width = NaN, float offset = 0, TransformedText? transformed = null, float tabStop = 0)

    Builds a line from its runs.

  • public float PenOf(int run)

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

  • public float WidthOf(int run)

    How wide a run is on this line, in pixels.

  • 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 float CaretOffset(int index, CaretAffinity affinity)

    Where a caret sits, given which side of the index it belongs to.

  • public void VisualRanges(int from, int to, List<(float X, float Width)> into)

    The stretches of the line a logical span covers, left to right.

  • public int CaretIndexAt(float x)

    Which caret index a distance along the line lands on.

  • public (int Index, CaretAffinity Affinity) CaretPositionAt(float x)

    Which caret a distance along the line lands on, and which side of it.

Used by (28)

  • BidiDirectionTestsVixen.Ui.Tests
  • BidiFallbackTestsVixen.Ui.Tests
  • BidiMirroringTestsVixen.Ui.Tests
  • CaretAffinityTestsVixen.Ui.Controls.Tests
  • CaretAffinityTestsVixen.Ui.Tests
  • CodeEditorVixen.Ui.Controls.Advanced
  • DrawListBuilderVixen.Ui
  • FontFallbackTestsVixen.Ui.Tests
  • FontFeatureStyleTestsVixen.Ui.Tests
  • FontRegistryTestsVixen.Ui.Tests
  • HyphensTestsVixen.Ui.Tests
  • LanguageTestsVixen.Ui.Tests
  • LineClampTestsVixen.Ui.Tests
  • SelectionRangeTestsVixen.Ui.Controls.Tests
  • TabSizeTestsVixen.Ui.Tests
  • TextFieldVixen.Ui.Controls
  • TextFieldTestsVixen.Ui.Controls.Tests
  • TextFloatBandTestsVixen.Ui.Tests
  • TextIndentTestsVixen.Ui.Tests
  • TextLayoutVixen.Ui
  • TextOverflowTestsVixen.Ui.Tests
  • TextTestsVixen.Ui.Tests
  • TextTransformTestsVixen.Ui.Tests
  • TextWrapTestsVixen.Ui.Tests
  • TrailingSpaceAlignmentTestsVixen.Ui.Tests
  • UiElementVixen.Ui
  • WhiteSpaceBreakSpacesTestsVixen.Ui.Tests
  • WhiteSpacePreTestsVixen.Ui.Tests