[skparagraph] Soft hyphen (U+00AD) rendering — CL 1193736 ready for review

18 views
Skip to first unread message

David H Bebawy

unread,
Mar 24, 2026, 5:44:31 PM (yesterday) Mar 24
to skia-d...@googlegroups.com
Hi,

I've implemented support for rendering visible hyphens at soft hyphen (U+00AD) line break positions in the skparagraph module.

CL: https://skia-review.googlesource.com/c/skia/+/1193736

Flutter issue: https://github.com/flutter/flutter/issues/18443 (302+ thumbs-up, open since 2018)

Problem: SkParagraph correctly breaks lines at U+00AD positions but never renders a visible hyphen at the break point. Per the Unicode standard, U+00AD should render as a visible hyphen when at a line break and remain invisible otherwise.

Root cause: Text is shaped as one long line first (via HarfBuzz), where U+00AD is shaped as zero-width/invisible. After line breaking, the invisible shaping is preserved.

The fix (6 files, +204 lines): When a line breaks at a soft hyphen, a visible hyphen glyph ("-") is shaped and appended to the line end, following the existing ellipsis pattern:

  • Cluster::isSoftHyphen() detects U+00AD clusters
  • TextLine::fHyphen stores the shaped hyphen Run (parallel to fEllipsis)
  • createSoftHyphen() reuses shapeEllipsis() infrastructure
  • Hyphen width is included in line width; painting works for both LTR and RTL
  • 4 new tests added; all 144 existing SkParagraph tests pass

Two requests:

  1. Bug tracker access: I'm unable to file bugs on issues.skia.org ("You do not have permission to create issues in this component"). Could someone file a bug for this, or grant me access? Draft below:

    Title: [skparagraph] Render visible hyphen at soft hyphen (U+00AD) line breaks

    Component: Skia > Paragraph

    When text containing soft hyphens (U+00AD) is laid out and a line break occurs at a soft hyphen position, no visible hyphen is rendered at the end of the line. Per the Unicode standard, U+00AD should render as a visible hyphen when at a line break, and remain invisible otherwise. SkParagraph correctly identifies U+00AD as a line break opportunity (via ICU), but since text is shaped as one long line first (where U+00AD is zero-width), the invisible shaping is preserved after line breaking.

    Related: https://github.com/flutter/flutter/issues/18443

    Fix: https://skia-review.googlesource.com/c/skia/+/1193736

  2. Code review: Who would be the right reviewer for skparagraph changes?

Thanks,
--

Julia Lavrova

unread,
10:38 AM (8 hours ago) 10:38 AM
to skia-d...@googlegroups.com

I reviewed the suggested changes.

The approach looks solid, and this new behavior is a useful addition to SkParagraph.
However, because several internal customers currently rely on the existing behavior, we can't safely roll this out as the new default without breaking their layouts.
Could we wrap this new functionality behind a run-time flag (perhaps added to ParagraphStyle)?
We will need the flag to default to the legacy behavior so that our existing users aren't impacted unless they explicitly opt-in to the new logic.
Let me know if you have any questions about where that flag should live. 

Thanks for the contribution.


--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/skia-discuss/CANbOCGXQdBMxf7YNxD397kNkUFY7Y0OAMK2qwAG9DXqrCMDenw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages