Skip to content

Match the Text Wrapping Behavior to p5.js Documentation #7780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mamatha1718
Copy link

@Mamatha1718 Mamatha1718 commented Apr 26, 2025

Resolves #7163

Changes:

  1. Added documentation for the textWrap() function in src/typography/loading_displaying.js.

  2. Included examples showing how to use textWrap(CHAR) and textWrap(WORD).

PR Checklist

Sorry, something went wrong.

Copy link
Collaborator

@perminder-17 perminder-17 left a comment

Choose a reason for hiding this comment

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

Hi @Mamatha1718 , Really thanks for working on this and I am really sorry for getting back to you this late. From now, you can tag me on the documentation PR's and I'll review/merge it within a day or two.

I see, now the tests are failing. Because textWrap() is already documented in the code, adding a second @method textWrap block here would only create a duplicate entry in the generated reference. The cleaner fix for the 1.x branch is therefore:

Replace the single-sentence note inside text(),

You should replace the below line in text() function,

  Text will wrap to fit within the text box. 

TO

By default p5.js wraps text **at word boundaries**.  
If you need exceptionally long words (e.g. URLs, CJK text without spaces) to fit
inside the same box, call `textWrap(CHAR)` first to wrap on every character.
Call `textWrap(WORD)`—or simply omit the call—to restore the default behaviour.

Feel free to write this in your own words, It's just the idea what needed to be done. That fulfils the request in issue #7163 without touching the rest of the description.

Add two extra example that demonstrates textWrap(CHAR) and textWrap(WORD).

If you see the examples, something like

<code>
your code....
</code>

So, you need to add examples which uses textWrap(CHAR) and textWrap(WORD) this will. Put this at the end of the existing @example series inside the same text() block.

Let me know if I am clear with the explanation, you should not need to add any additional JSDoc tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text Wrapping Behavior in p5.js doesn't match the documentation
2 participants