Add fontWidth() and clarify textWidth vs fontWidth docs in textCore.js #7745#8088
Add fontWidth() and clarify textWidth vs fontWidth docs in textCore.js #7745#8088NalinDalal wants to merge 7 commits into
Conversation
|
Hi @NalinDalal , thank you for your work and enthusiasm on this, however this PR is quite a bit beyond the scope of the original issue. The issue is with clarify in documentation only; both fontWidth and textWidth are part of p5.js 2.0, and it's true that no functionality changes to That means JSDoc on the existing I noticed another person wanted to work on this, so if they want to work on this issue, please let them go ahead:
If they respond on the original issue that they're not interested, I'm happy to assign it to you and help you finish this PR. However, if they want to work on this, please close this PR; thank you for your understanding! |
|
I will then just mark it as draft then, thanks for your comments |
….js; simple docs are updated, not code
|
Thanks so much for your work and enthusiasm on this! As Kit noted above, another contributor is already actively working on this issue. To follow our contributor guidelines, I’m going to close this PR for now. If for any reason the other effort stalls or can’t be completed, we’ll be happy to revisit and help adapt your changes here. Apologies for the inconvenience, and thank you again for your understanding and contributions, we really appreciate it. |
Resolves #7745
Adds a new user-facing function,
fontWidth(), to the p5.js library and updates the documentation to clearly distinguish between advance width and tight bounding box measurements for text. All changes are made insrc/type/textCore.js.Changes
New Function:
fontWidth()returns the advance width (loose measurement) of a string, including all leading and trailing whitespace, as measured by the browser’smeasureText().width.Documentation Updates:
fontWidth().textWidth()documentation to clarify that it returns the tight bounding box width, which may ignore leading/trailing whitespace.Motivation
textWidth()and the newfontWidth()regarding whitespace handling.Example Usage
Related Issues
Checklist
fontWidth()src/type/textCore.jsp5.Font.jsdev-2.0branchPR Checklist
npm run lintpasses