Skip to content

fix: honor zero-width spaces when wrapping text - #1180

Merged
imaginarny merged 2 commits into
kaplayjs:masterfrom
snowyukitty:fix/zero-width-text-breaks
Oct 16, 2026
Merged

imaginarny merged 2 commits into
kaplayjs:masterfrom
snowyukitty:fix/zero-width-text-breaks

Conversation

@snowyukitty

Copy link
Copy Markdown
Contributor

PR Overview

Treat U+200B as an invisible word-break opportunity. Text such as AB\u200BCDEF can wrap before CDEF without displaying a space or forcing a newline when the whole text fits.

List of changes

  • Closes feat: let \u200B (zero width space) do word break in text #902.
  • Remember the source cursor, retained glyph count and advance at each break, so invisible characters do not shift the text when wrapping.
  • Preserve ordinary-space trimming, character indices, styles, letter spacing and alignment. Initialize system-font metrics from a character after any leading U+200B.
  • Add browser integration regressions, including a pixel comparison of the real text() component against equivalent explicit line breaks.

Validation from the repository root on Node 24 and Linux Chromium:

  • npm run build and npm run check passed.
  • npm run test -- --reporter=line --workers=2: 98 tests passed; unmodified upstream passes its original 87 tests.
  • With only the new test file applied, 8 of its 11 cases fail on the original implementation; 3 controls pass.
  • npm exec -- dprint check passed. ESLint passed for the two changed source files; integration tests are outside its configured scope.

Windows, macOS and other browsers were not run locally. This does not add general Unicode line-breaking rules.

Contributor Checks

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OHHI! Congratulations on your first PR. If you're a new developer, enjoy this journey and be sure KAPLAY repo is one of the best places to do your first contributions. If you're experienced dev, thank you :>

@imaginarny imaginarny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are hesitant about contributions like these and evaluate them case-by-case, but the change was small and wouldn't do it any differently really. Although, note that (not you particularly, but in general) human is always going through them and will spend their time on them. So I hope some human care went into this as well. Sry if assuming wrong, It's getting harder. Thank you! 😇

@imaginarny
imaginarny merged commit 787a70f into kaplayjs:master Oct 16, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Inbox to Done in PR Tracking Sheet Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: let \u200B (zero width space) do word break in text

2 participants