Vixen
feb85697
csharp
public enum WhiteSpaceCollapse

What happens to white space before it is shaped. CSS Text 4 § 3's white-space-collapse.

Read the guide page for this →

Remarks

⚠ Two members where CSS has five, and the three that are missing are missing because nothing here can produce them. collapse and preserve-spaces both turn a segment break into a space — which is a decision about line breaking and not about the string, since this engine takes every mandatory break — and break-spaces is a preserving value that differs from preserve in two line-breaking rules that LineWrapper already answers behind its own flag. Offering a member that resolved, computed a value and did nothing is the state this repository's gates exist to keep out.

Phase I, and the part of phase II that is a question about the string. § 4.1.1 is a transformation of the string. § 4.1.3's phase II — a collapsible space at the start or the end of a line is removed — reads like a question about lines, which do not exist yet when a string is transformed. ⚠ But after phase I there are only two places a line can begin or end on a collapsible space the wrapper does not already handle, and both are string positions. Every run in the middle has become one space with a break opportunity after it (UAX #14 breaks after spaces and never before them), so a soft wrap leaves the space at the end of the earlier line, where LineWrapper's trailing trim already takes it out of the measure; every run touching a segment break is gone. What is left is a run at the very start of the text and one at the very end — and for a paragraph whose first line starts a line box and whose last line ends one, those are line edges. TransformedText.Of's trimStart and trimEnd are that condition, one per end, because for a display: inline element the two ends can have different answers — its remarks say which.

⚠ So phase II was owed for one value, not six. Under pre, pre-wrap and break-spaces a space is preserved rather than collapsible and phase II does not apply to it — Chrome draws a pre-wrap paragraph's leading space. Under normal and nowrap it applies, but so does phase I, and this engine performs neither there deliberately: an undeclared paragraph renders as CSS's pre-wrap, and collapsing it would move every label in every interface. ⚠ One corner was a question about a line, and it is answered in the wrapper rather than here: a break that falls before a space. It was narrower than it was written down as — only a room narrower than one letter can put a break there, under line-break: anywhere or overflow-wrap: anywhere, because a break after the space fits whenever one before it does — and where it happened the space became a line of its own. LineWrapper.PastHangingSpaces hangs it on the line before instead (#249).

Fields and properties (2)

  • Preserve

    Every space, tab and segment break survives into the shaped text.

  • PreserveBreaks

    Runs of spaces and tabs collapse; segment breaks survive. CSS's preserve-breaks.

Used by (4)

  • TransformedTextVixen.Ui.Text
  • UiDocumentVixen.Ui
  • UiElementVixen.Ui
  • WhiteSpaceCollapseTestsVixen.Ui.Text.Tests