Skip to content

[Skia] CR and LF in different inlines make one line break; WinUI makes two #26148

Open

Description

@mikernet

Current behavior

On Skia, a TextBlock with a carriage return (U+000D) at the end of one inline and a line feed (U+000A) at the start of the next breaks the line once. WinUI breaks it twice. A LineBreak element counts as a line feed in the same way.

Inlines WinUI (Windows App SDK 1.8) Uno master (Skia desktop)
Run("a\r") + LineBreak + Run("b") 3 lines 2 lines
Run("a\r") + Run("\nb") 3 lines 2 lines

Both agree when the CR and LF are in the same Run (Run("a\r\nb") and Run("a") + Run("\r\nb") give 2 lines), and when the two breaks aren't a CR followed by an LF (Run("a\n") + LineBreak + Run("b") gives 3 lines).

The WinUI numbers are line counts from ActualHeight and the position of b, for a TextBlock with no wrapping.

Expected behavior

The same line count as WinUI: a CR that ends one inline and an LF that starts the next are two line breaks.

Cause

UnicodeText computes line-break opportunities over the whole text, since #23924. ICU treats CR LF as a single break wherever the two characters come from, so the pair merges across the inline boundary. The comment there says the merge is intended:

Line breaking is a document-level operation. Computing boundaries per inline can split a CRLF pair when character formatting changes between its two code units.

That reads as a RichEditBox concern, where a CRLF pair can straddle a formatting change. For TextBlock, WinUI keeps the inline boundary between the two breaks.

Question

Should TextBlock match WinUI here, for example by keeping a mandatory break at an inline boundary where one inline ends with CR and the next starts with LF, while RichEditBox keeps the pair together?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions