Vixen
02b45cc4
csharp
public static class TextItemizer

Cuts a paragraph into the runs a shaper can be given.

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

Remarks

A shaper works on one direction, one script and one font at a time, so something has to decide where those change. That is this, and it is the part of text rendering Vixen actually owns — HarfBuzz does the shaping, but it shapes whatever it is told to, so a wrong answer here produces wrong glyphs out of a correct shaper. The text-rendering-tests suite is sensitive to exactly this, which is why it is the gate.

Cutting too finely is as wrong as cutting in the wrong place. Shaping depends on context: a substitution can be conditioned on the character after the one it replaces, and the Consortium has a test case named Space Isn't Nothing for the specific mistake of treating a space as a run boundary. So the rule is to cut only where the shaper genuinely cannot carry on, and to let everything neutral join whatever surrounds it.

Methods (2)

  • public static List<TextItem> Itemize(string text, ParagraphDirection direction = Auto)

    Cuts a paragraph into runs, in logical order.

  • public static int[] VisualOrder(IReadOnlyList<TextItem> items)

    Puts runs into the order they are drawn in, left to right.

Used by (2)

  • ShapingTestsVixen.Ui.Text.Tests
  • TextShaperVixen.Ui.Text