feat(typography): add PRETTY/BALANCE textWrap modes with DP-based balanced wrapping
PR2
- Adds textWrap(PRETTY) and textWrap(BALANCE) to improve line-breaking aesthetics.
- Uses dynamic programming to minimize raggedness; last line has zero penalty.
- Integrates with existing text flow in 2D; works with all alignments, including JUSTIFIED .
- Lint/build pass locally.
Addresses and resloved #7712
🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors! 🤔 Please ensure that your PR links to an issue, which has been approved for work by a maintainer; otherwise, there might already be someone working on it, or still ongoing discussion about implementation. You are welcome to join the discussion in an Issue if you're not sure! 🌸 Once your PR is merged, be sure to add yourself to the list of contributors on the readme page !
Thank You!
Hello @osteele @andrewn @zeke @reidab sir can u please review my PR.
@Vansh0204 have you created tests for this feature?
Thanks for reviewing, sir! I haven't added tests yet – I'll add comprehensive unit tests for the PRETTY/BALANCE textWrap modes covering the main functionality and edge cases. I'll push them shortly.
a good place to start would be the alignment tests in https://github.com/processing/p5.js/blob/dev-2.0/test/manual-test-examples/type/index.html
eventually we will also need pixel-based tests like those here: https://github.com/processing/p5.js/blob/dev-2.0/test/unit/visual/cases/typography.js
Hi @dhowe, sir! I've updated the PRs to include the necessary tests.
Sorry, did you make this PR against the dev-2.0 branch ?
Yes sir, the PR is currently targeting dev-2.0. Should I change the base branch to main instead, or would you prefer I rebase my changes on top of dev-2.0? Let me know which branch you'd like me to target, and I'll update accordingly.
Yes sir, the PR is currently targeting dev-2.0. Should I change the base branch to main instead, or would you prefer I rebase my changes on top of dev-2.0? Let me know which branch you'd like me to target, and I'll update accordingly.
I'm seeing main as the target for this pr:
Yes @dhowe sir, that's correct! The PR is targeting main. I can see it shows "base: main" at the top of the PR. Let me know if there's anything else you'd like me to address!
both of these PR's need to target dev-2.0 as we're not adding features to v1.x (which his still main) at this point
@dhowe sir, I have to work on it.
Hi @osteele and @dhowe, sir, I have raised new PRs can you please review them. Should I close these two PRs?
Hi @osteele and @dhowe, sir, I have raised new PRs can you please review them. Should I close these two PRs?
yes please
and thanks for your work!
Thank you, @dhowe sir for your guidance.
@dhowe Sir, one last request, can you please review my new PRs?